What is SDK Generation?
SDK generation creates client libraries from your API contract. Instead of writing HTTP client code by hand for each language, you define your API once and generate clients automatically.Quick Start
Generate SDK clients using the CLI:Why Use Native SDK Generators?
Benefits Over Manual Client Code
| Aspect | Manual Code | Generated SDK |
|---|---|---|
| Type Safety | Error-prone, manual sync | Always matches server |
| Maintenance | Update everywhere | Regenerate once |
| Consistency | Varies by author | Uniform patterns |
| Time to Ship | Hours per language | Seconds |
Benefits Over Generic OpenAPI-Based Generation
| Feature | Generic Generators | Mizu SDK Generators |
|---|---|---|
| Code Style | Generic, verbose | Idiomatic, minimal |
| Dependencies | Often many | Minimal (stdlib-focused) |
| API Feel | HTTP-centric | Resource-oriented |
| Streaming | Limited support | First-class SSE |
| Size | Large output | Compact, focused |
When to use OpenAPI generators? OpenAPI generators support 40+ languages and have mature tooling. Use them when you need languages Mizu doesnβt support natively, or when you need OpenAPI compatibility with other tools. See Client Generation for OpenAPI approaches.
Available SDK Generators
Mizu provides native SDK generators for three languages:Go
Zero dependencies, stdlib only. Fluent resource-based API with EventStream for streaming.
Python
Modern Python with type hints. Sync and async clients using httpx.
TypeScript
Runtime agnostic (Node/Bun/Deno). AsyncIterable streaming with full type inference.
Quick Comparison
| Feature | Go SDK | Python SDK | TypeScript SDK |
|---|---|---|---|
| Output | Single .go file | uv/pip project | npm package |
| HTTP Client | net/http | httpx | native fetch |
| Streaming | EventStream[T] | Iterator/AsyncIterator | AsyncIterable<T> |
| Dependencies | None (stdlib) | httpx | None |
| Runtimes | Go 1.18+ | Python 3.8+ | Node 18+/Bun/Deno |
How It Works
Step 1: Define Your Contract
Create a contract definition in YAML:Step 2: Generate SDK Clients
Step 3: Use the Generated Clients
CLI Reference
Command Syntax
Flags
| Flag | Short | Description | Default |
|---|---|---|---|
--lang | Target language: go, golang, python, py, typescript, ts, all | typescript | |
--output | -o | Output directory | Same as input file |
--package | Package/module name | Derived from service name | |
--version | Package version (Python/TypeScript) | 0.0.0 | |
--client | -c | Generate full SDK client (not just types) | false |
Examples
Choosing the Right Approach
Use this decision matrix to choose between SDK generation and OpenAPI:| If you need⦠| Use |
|---|---|
| Go, Python, or TypeScript client | Native SDK generators |
| Maximum type safety | Native SDK generators |
| Minimal dependencies | Native SDK generators |
| Streaming (SSE) support | Native SDK generators |
| Other languages (Java, Ruby, etc.) | OpenAPI generators |
| OpenAPI ecosystem compatibility | OpenAPI generators |
| Both approaches | Both! Generate native SDKs and serve /openapi.json |
CI/CD Integration
Regenerate SDKs on contract changes:Whatβs Next?
Go
Complete guide to generating and using Go SDKs
Python
Complete guide to generating and using Python SDKs
TypeScript
Complete guide to generating and using TypeScript SDKs
OpenAPI Generation
Alternative approach using OpenAPI specification
See Also
- Service Definition - How to define your API interface
- Types - Type system and mappings
- Client Generation - OpenAPI-based approach
- REST Transport - Exposing your service as REST API