4 Languages, One API

Meet AI SDK

Official client libraries for the Koder AI Gateway API. Integrate AI capabilities into your applications with idiomatic, type-safe SDKs for Go, TypeScript, Python, and Dart.

// Quick start with Go
import "flow.koder.dev/koder/koder-ai-sdk/go"

client := sdk.New("your-api-key")

resp, _ := client.Chat.Complete(ctx, sdk.ChatRequest{
    Model: "gpt-4o",
    Messages: []sdk.Message{
        {Role: "user", Content: "Hello!"},
    },
})

fmt.Println(resp.Choices[0].Message.Content)

Built for Developers

Everything you need to integrate AI into your applications, with best practices baked in.

Type-Safe

Full type definitions in every language. Catch errors at compile time, not at runtime. Auto-complete works out of the box in your IDE.

Streaming

Real-time streaming with idiomatic iterators in each language. Go channels, async generators in TS, async iterators in Python, Dart Streams.

Error Handling

Specific error types for auth failures, rate limits, validation errors, and server errors. No more guessing what went wrong.

OpenAI Compatible

Drop-in replacement for the OpenAI SDK. Just change the base URL and API key. Switch providers without touching your business logic.

Multi-Language

First-class SDKs for Go, TypeScript, Python, and Dart. Same capabilities, idiomatic APIs. Use the language your team knows best.

Auto-Retry

Automatic retries with exponential backoff for transient errors. Configurable retry count, backoff strategy, and retry-on conditions.

Go

Idiomatic Go SDK with full type safety, context support, and streaming via channels.

  • Install: go get flow.koder.dev/koder/koder-ai-sdk/go
  • Context-aware with cancellation support
  • Streaming via Recv() loop pattern
  • Zero external dependencies
// Streaming chat completion in Go
stream, _ := client.Chat.Stream(ctx, sdk.ChatRequest{
    Model: "gpt-4o",
    Messages: []sdk.Message{
        {Role: "user", Content: "Write a haiku"},
    },
})

for {
    chunk, err := stream.Recv()
    if err == io.EOF { break }
    fmt.Print(chunk.Choices[0].Delta.Content)
}

TypeScript

Modern TypeScript SDK with async/await, full generics, and tree-shakeable ESM imports.

  • Install: npm install @koder/ai-sdk
  • Full TypeScript generics and type inference
  • Streaming via async generators
  • Works in Node.js, Deno, Bun, and browsers
// Streaming chat completion in TypeScript
const client = new KoderAI("your-api-key");

const stream = await client.chat.stream({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Write a haiku" }],
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0].delta.content);
}

Python

Async-first Python SDK with Pydantic models, type hints, and native asyncio support.

  • Install: pip install koder-ai-sdk
  • Full Pydantic model validation
  • Async iterators for streaming
  • Sync wrapper available for simple scripts
# Streaming chat completion in Python
async with KoderAI("your-api-key") as client:
    stream = await client.chat.stream(
        model="gpt-4o",
        messages=[{"role": "user", "content": "Write a haiku"}],
    )

    async for chunk in stream:
        print(chunk.choices[0].delta.content, end="")

Dart

Flutter-ready Dart SDK with strong typing, null safety, and native Stream support.

  • Install: dart pub add koder_ai_sdk
  • Full null safety and strong typing
  • Native Dart Streams for real-time responses
  • Works in Flutter mobile, desktop, and web
// Streaming chat completion in Dart
final client = KoderAI('your-api-key');

final stream = client.chat.stream(
  ChatCompletionRequest(
    model: 'gpt-4o',
    messages: [Message(role: 'user', content: 'Write a haiku')],
  ),
);

await for (final chunk in stream) {
  stdout.write(chunk.choices[0].delta.content);
}

How It Compares

See how Koder AI SDK stacks up against other AI client libraries.

FeatureKoder AI SDKOpenAI SDKAnthropic SDKGoogle AI SDKDirect HTTP
Multi-provider support
Go SDKManual
TypeScript SDKManual
Python SDKManual
Dart / Flutter SDKManual
Streaming supportManual
Auto-retry with backoffPartial
OpenAI-compatible API
Open-sourceN/A

Frequently Asked Questions

Yes. The Koder AI Gateway exposes an OpenAI-compatible API. You can use these SDKs as a drop-in replacement for the official OpenAI libraries by pointing them to the Koder AI Gateway endpoint.

The available models depend on your Koder AI Gateway configuration. Use the Models.list() method to discover all models available on your instance, including models from OpenAI, Anthropic, Google, Meta, and Mistral.

Yes. All four SDKs support streaming with idiomatic patterns: Go uses a Recv() loop, TypeScript uses async generators, Python uses async iterators, and Dart uses Streams.

Yes. All SDKs accept a custom HTTP client for advanced use cases like custom TLS certificates, proxies, or logging middleware. You can bring your own transport layer.

Yes. The Koder AI SDK is released under the MIT License. Contributions are welcome on the source repository.

Install the Koder AI SDK, change your base URL to the Koder AI Gateway endpoint, and swap your API key. The request and response formats are identical to OpenAI's, so your existing code works as-is.

Start building with AI in minutes

Four languages. One API. Type-safe, streaming, production-ready.

Download View on Flow