SDKs and libraries

Claud does not ship its own SDK because it does not need one. The API speaks two widely-supported wire formats, so every client library, framework and tool that talks to either works with Claud by changing a base URL and a key:

  • OpenAI Chat Completions format at POST /v1/chat/completions — used by the OpenAI SDKs, Vercel AI SDK, LangChain, LlamaIndex, Cursor, Continue, Open WebUI and most other tooling.
  • Anthropic Messages format at POST /v1/messages — used by the Anthropic SDKs, Claude Code and tools with an "Anthropic base URL" setting.
SettingValue
Base URL (OpenAI format)https://api.claudkey.com/v1
Base URL (Anthropic format)https://api.claudkey.com (SDKs append /v1/messages)
API keyYour sk-... key
ModelA Claud model slug such as claud-5.1
Just a wire format

Claud is an independent service. Supporting these request formats means your existing code and tools work unchanged; it does not mean Claud is affiliated with, or proxies to, the companies that designed them. Every request is served by a Claud model.

Official OpenAI SDKs#

// npm install openai
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.CLAUD_API_KEY,
  baseURL: 'https://api.claudkey.com/v1',
});

const res = await client.chat.completions.create({
  model: 'claud-5.1',
  messages: [{ role: 'user', content: 'Hello, Claud!' }],
});
console.log(res.choices[0].message.content);

Reading Claud-specific fields#

The SDKs preserve fields they do not know about. Cost information is available on every response:

const res = await client.chat.completions.create({ model: 'claud-5.1', messages });
console.log(res.usage.claud_tokens_debited, res.usage.claud_cost_usd);

// Headers, via the raw response helper
const { data, response } = await client.chat.completions.create({ model: 'claud-5.1', messages }).withResponse();
console.log(response.headers.get('x-claud-balance'));

Anthropic SDKs and Claude Code#

The Anthropic client libraries send requests in the Messages format to {baseURL}/v1/messages with the key in an x-api-key header. Point them at Claud's origin (without /v1) and use a Claud model slug:

// npm install @anthropic-ai/sdk
import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  apiKey: process.env.CLAUD_API_KEY,
  baseURL: 'https://api.claudkey.com',
});

const msg = await client.messages.create({
  model: 'claud-5.1',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Hello, Claud!' }],
});
console.log(msg.content[0].text);

// Streaming
const stream = client.messages.stream({ model: 'claud-5.1', max_tokens: 1024, messages: [{ role: 'user', content: 'Tell me a story.' }] });
for await (const event of stream) {
  if (event.type === 'content_block_delta' && event.delta.type === 'text_delta') process.stdout.write(event.delta.text);
}

Tool use (tools / tool_use / tool_result blocks), system prompts, image blocks and stop_sequences are all translated. Reasoning models return thinking content blocks when thinking: { type: "enabled" } is set. The usage object carries the standard input_tokens / output_tokens fields plus claud_tokens_debited and claud_cost_usd.

To run Claude Code against Claud, set two environment variables and start it as normal:

Shell
export ANTHROPIC_BASE_URL=https://api.claudkey.com
export ANTHROPIC_AUTH_TOKEN=$CLAUD_API_KEY   # or ANTHROPIC_API_KEY
export ANTHROPIC_MODEL=claud-5.1              # optional: default model
claude

See Cursor, Claude Code & tools for step-by-step setup of coding assistants and chat UIs.

Frameworks#

// npm install ai @ai-sdk/openai-compatible
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText, streamText } from 'ai';

const fable = createOpenAICompatible({
  name: 'fable',
  apiKey: process.env.CLAUD_API_KEY!,
  baseURL: 'https://api.claudkey.com/v1',
});

const { text } = await generateText({
  model: fable('claud-5.1'),
  prompt: 'Summarise the plot of Hamlet in one paragraph.',
});

// or stream in a route handler
const result = streamText({ model: fable('claud-flash'), prompt: 'Hello!' });
return result.toTextStreamResponse();

Plain HTTP#

Any HTTP client works. The essentials:

HTTP
POST /v1/chat/completions HTTP/1.1
Host: api.claudkey.com
Authorization: Bearer sk-...
Content-Type: application/json

{"model":"claud-5.1","messages":[{"role":"user","content":"Hello"}]}
  • Send JSON with Content-Type: application/json; bodies up to 2 MB.
  • For streaming, read the body incrementally and split on blank lines; each event is data: <json> and the stream ends with data: [DONE].
  • Retry 429/5xx with back-off and honour retry-after. See Errors.

Compatibility notes#

Claud implements the Chat Completions surface faithfully. Differences to be aware of:

AreaBehaviour
nOnly 1 is supported.
logprobsAccepted; always returns null.
response_format.json_schemaTreated as json_object; validate the output yourself.
developer roleAccepted and mapped to system.
max_completion_tokensSupported; takes precedence over max_tokens.
reasoning_effort / thinkingSupported on reasoning models; see Reasoning controls.
usageIncludes claud_tokens_debited and claud_cost_usd; streams add a final fable billing event.
Other endpointsOnly /v1/chat/completions and /v1/models follow the OpenAI shape. Embeddings, images, audio and files are not offered.

Unknown top-level parameters are ignored rather than rejected, so libraries that send extra fields keep working.