TypeScript SDK API Reference

While the complete API reference is centralized in the main API documentation, this page highlights key functions to get you started quickly.

Commonly Used Functions

  • claude.query(prompt: string, options?: QueryOptions): The primary function for interacting with Claude. It sends a prompt and returns the response.
  • claude.stream(prompt: string, options?: QueryOptions): Use this for real-time, streaming responses.

Getting Started Example

Here’s a simple example of how to use the SDK:

import { claude } from '@anthropic-ai/claude-code';
 
async function getGreeting() {
  const response = await claude.query("Write a one-sentence greeting.");
  console.log(response);
}
 
getGreeting();

→ View the Complete API Reference


Tags: claude-code typescript sdk api reference