Mission
ai_sdk aims to minimise boilerplate when working with modern LLMs while staying provider-agnostic and fully typed.
- One-line helpers (
generate_text,embed_many, …) do 90 % of common work. - Abstract base classes (
LanguageModel,EmbeddingModel) keep providers pluggable. - Pydantic models enforce type-safety for structured output & internal messages.
- Everything is sync-first for notebooks/scripts but exposes async streaming where it matters.
High-level flow
1
Factory helper returns a provider wrapper
2
Helper builds a provider-agnostic request
The SDK translates
prompt/system/messages/tools into the provider’s native schema.3
Provider SDK call & response normalisation
Each provider implementation maps the raw response back into a lightweight dict containing
text, finish_reason, usage, raw_response, …4
Result objects give you typed access
Where does retry logic live?
- Embeddings - batching & retries happen in the helper (
embed_many). - Text generation - delegate retries to the provider’s SDK since most include back-off handlers.
Extending the SDK
- Implement
LanguageModelorEmbeddingModel. - Expose a public factory (e.g.
mycloud(model="x")). - Users instantly get the full helper surface - no changes elsewhere.
Roadmap
- Built-in vector-store utilities
- Native image generation helpers
- Automatic schema extraction for
generate_object
Open to contributions! Check the GitHub issues for “good first issue” labels.