TypeScript Quickstart
Using the Curate-Me TypeScript SDK (Recommended)
The SDK configures the OpenAI client to route through the gateway automatically:
npm install @curate-me/sdk openaiimport OpenAI from 'openai';
import { CurateGateway } from '@curate-me/sdk';
const gw = new CurateGateway('cm_sk_xxx');
// Get a pre-configured OpenAI client config pointed at the gateway
const client = new OpenAI(gw.openaiConfig());
const response = await client.chat.completions.create({
model: 'anthropic/claude-haiku-4-5',
messages: [{ role: 'user', content: 'Hello from TypeScript!' }],
});
console.log(response.choices[0].message.content);You can also pass a provider key explicitly if you are not using stored secrets:
const client = new OpenAI(gw.openaiConfig('sk-your-openai-key'));Using the OpenAI SDK Directly
If you prefer not to use the SDK, just change the base URL:
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.curate-me.ai/v1/openrouter',
apiKey: 'stored',
defaultHeaders: { 'X-CM-API-Key': 'cm_sk_xxx' },
});
const response = await client.chat.completions.create({
model: 'anthropic/claude-haiku-4-5',
messages: [{ role: 'user', content: 'Hello from TypeScript!' }],
});
console.log(response.choices[0].message.content);Streaming
const stream = await client.chat.completions.create({
model: 'anthropic/claude-haiku-4-5',
messages: [{ role: 'user', content: 'Write a haiku about AI governance.' }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}