codai docs
SDKs

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.

TypeScriptPython
Packagecodai-sdk 0.2.3codai-sdk 0.1.1
Importimport { Codai } from 'codai-sdk'from codai import Codai
RuntimeNode 18+, edge runtimes with fetchPython 3.9+
Dependenciesnonenone (stdlib urllib)
Streamingasync iterator + .final metadatagenerator of text deltas
Retries429 / 5xx, exponential backoff, 2 by defaultsame

Install

pnpm add codai-sdk

Thirty-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

SurfaceTypeScriptPython
Chat (/v1/chat/completions)chat()chat()
Streaming chatchatStream()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-textaudio.transcribe()transcribe()
Text-to-speechaudio.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.

On this page