# TypeScript > Node examples with @anthropic-ai/sdk and openai, including streaming. _Source: https://aiprimetech.io/docs/sdks/typescript/ · Home > Docs > SDKs_ ## Anthropic SDK ```bash npm install @anthropic-ai/sdk ``` ```typescript import Anthropic from "@anthropic-ai/sdk"; const client = new Anthropic({ apiKey: process.env.CLAUDEAPIKEY!, baseURL: "https://aiprimetech.io", // no /v1 }); const msg = await client.messages.create({ model: "claude-sonnet-4-6", max_tokens: 1024, messages: [{ role: "user", content: "Explain event loops briefly." }], }); const block = msg.content[0]; if (block.type === "text") console.log(block.text); ``` > `content` is a discriminated union. Narrow on `block.type === "text"` rather than indexing blindly — a tool-use reply has no `.text` and will be `undefined` at runtime. ## Streaming ```typescript const stream = await client.messages.stream({ model: "claude-sonnet-4-6", max_tokens: 1024, messages: [{ role: "user", content: "Count to five." }], }); for await (const event of stream) { if (event.type === "content_block_delta" && event.delta.type === "text_delta") { process.stdout.write(event.delta.text); } } const final = await stream.finalMessage(); console.log(final.usage); ``` ## OpenAI SDK ```typescript import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.CLAUDEAPIKEY!, baseURL: "https://aiprimetech.io/v1", // with /v1 }); const r = await client.chat.completions.create({ model: "claude-sonnet-4-6", messages: [{ role: "user", content: "Hello" }], }); console.log(r.choices[0].message.content); ``` > Never ship a key in browser-side code. Call the gateway from your server and expose your own endpoint to the front end — anything in a bundle is public. - [Chat Completions](https://aiprimetech.io/docs/api-reference/chat-completions/) — OpenAI-format reference - [Best practices](https://aiprimetech.io/docs/guides/best-practices/) — Production concerns --- _ClaudeAPIKey.dev is an independently operated, Anthropic-compatible API gateway. Not affiliated with Anthropic._