OverviewMembers

Claude API TypeScript SDK guide

Claude API for TypeScript is the TypeScript section of Anthropic's claude-api skill, for developers calling Claude from Node or TypeScript projects. It covers npm install @anthropic-ai/sdk, a client that reads credentials from the environment, the basic messages.create request, system prompts, images, and a beta user profiles feature.

What it does

It warns that __dirname and __filename are undefined in ES modules and shows safe relative file reads. It also notes that response.content is a union you narrow by type before reading text.

How to use it

Claude Code reads it when TypeScript code uses the Anthropic SDK, so generated code compiles and follows these patterns.

Requirements and limits

User profiles sit in the beta namespace and need a beta header listed in the SDK's beta-headers reference.

More in Overviews and the Claude Code library.

What it covers

  • Installation
  • Client Initialization
  • Basic Message Request
  • System Prompts
  • Mid-conversation system messages model-gated
  • Vision Images
  • URL
  • Base64
  • Prompt Caching
  • Automatic Caching Recommended

The full text is in the members library

Book a call and we will give you access to the full Claude Code library: every entry in full, search by meaning, copy and download.

Source and license

Source: https://github.com/anthropics/skills/blob/main/skills/claude-api/typescript/claude-api/README.md

Author: anthropics, Anthropic skills. License: Apache-2.0.

Related entries