SDKs
Official TypeScript and Python clients for the codai gateway — zero dependencies, typed, with codai extensions built in.
Both SDKs are thin, dependency-free wrappers over the gateway's HTTP API. They exist so you do not have to hand-roll SSE parsing, tool-call assembly, retries or the X-Codai-* headers — and so codai extensions (sessions, agent mode, compaction, best-of) are one option away instead of a header you have to remember.
| TypeScript | Python | |
|---|---|---|
| Package | codai-sdk 0.2.3 | codai-sdk 0.1.1 |
| Import | import { Codai } from 'codai-sdk' | from codai import Codai |
| Runtime | Node 18+, edge runtimes with fetch | Python 3.9+ |
| Dependencies | none | none (stdlib urllib) |
| Streaming | async iterator + .final metadata | generator of text deltas |
| Retries | 429 / 5xx, exponential backoff, 2 by default | same |
Install
pnpm add codai-sdkThirty-second tour
import { Codai } from 'codai-sdk';
const codai = new Codai({ apiKey: process.env.CODAI_API_KEY!, sessionId: 'my-project' });
const res = await codai.chat({ messages: [{ role: 'user', content: 'hello' }] });
console.log(res.content, res.routedTo);
for await (const delta of codai.chatStream({ messages: [{ role: 'user', content: 'hi' }] })) {
process.stdout.write(delta);
}
const run = await codai.agents.run({ task: 'Summarize the repo structure.' });
if (res.requestId) await codai.feedback(res.requestId, 1);What both clients cover
| Surface | TypeScript | Python |
|---|---|---|
Chat (/v1/chat/completions) | chat() | chat() |
| Streaming chat | chatStream() | chat_stream() |
Server-side agent (/v1/agents/run) | agents.run() | agents_run() |
Feedback (/v1/feedback) | feedback() | feedback() |
Models (/v1/models) | models() | models() |
Ephemeral tokens (/v1/tokens) | mintToken() | mint_token() |
Embeddings (/v1/embeddings) | embeddings() | embeddings() |
| Speech-to-text | audio.transcribe() | transcribe() |
| Text-to-speech | audio.speech() | speech() |
Anthropic Messages, the Responses API, realtime WebSockets, the receipt endpoint and the shared-sessions protocol are not wrapped yet — call them directly or through the OpenAI / Anthropic SDKs as shown in the gateway quickstart.
Memory and skills are server-side
The memory tools (memory_recall, memory_remember) and skills (use_skill) are gateway-native: when you pass a stable sessionId, the model can invoke them during the request and the gateway executes them. There is nothing to call from the SDK beyond enabling a session.
Tasks and spend
What a task is, how plan caps and spend caps show up as 429s, why a task can wait for your confirmation, and the /v1/tasks endpoints.
TypeScript
The codai-sdk package for Node and edge runtimes — configuration, resource groups with full OpenAPI parity, chat, streaming, agents, sessions, errors and migrating from the OpenAI SDK.