npx skills add ...
npx skills add vercel-labs/py-ai --skill ai
AI SDK for Python (the `ai` package). Use when writing Python that calls LLMs or dedicated image, video, speech, embedding, transcription, or reranking models; builds agents; tests model interactions; or implements tool calling, subagents, approvals, durable execution, telemetry, AI SDK UI backends, and custom providers.
This repo is now called vercel-labs/ai-python. Both names install the same content, but the install count here only covers this one.
npx skills add vercel-labs/py-ai --skill ai
Package: ai. Requires Python 3.12+. Install with uv add ai.
Unprefixed model IDs use AI Gateway and AI_GATEWAY_API_KEY. Direct providers
use provider:model, their API key, and an extra:
Use ai.stream for one model call without Python tool execution:
Use ai.Agent for a loop that executes Python tools and manages history:
These examples are sufficient for basic model calls, messages, tools, and agents.
For an advanced task, fetch its page under https://ai-python.dev/docs/ and
read the listed local notes before writing code.
| Task | Page | Local notes |
|---|---|---|
| Provider clients, options, discovery | basics/providers.md | — |
| Structured output, complex streams | basics/streaming.md | — |
| Buffered language-model calls | basics/streaming.md | — |
| Images, video, speech, embeddings, transcription, reranking | basics/model-operations.md | — |
| Events and serialization | basics/messages-and-events.md | — |
| Advanced tools, streaming, aggregation | basics/tools.md | streaming-tools.md |
| Advanced agent behavior | basics/agents.md | — |
| Deterministic model and agent tests | basics/testing.md | — |
| Subagents and multi-agent | basics/subagents-and-multi-agent.md | streaming-tools.md |
| Custom agent loops | basics/custom-loops.md | custom-loops.md |
| Approvals and hooks | basics/human-in-the-loop.md | — |
| Serverless resume | basics/human-in-the-loop.md | serverless.md |
| Durable execution | basics/durable-execution.md | durable.md |
| Telemetry and tracing | basics/telemetry.md | — |
| AI SDK UI backends | basics/ai-sdk-ui.md | ui.md |
| Custom providers | basics/providers.md | custom-provider.md |
For exact APIs, use reference.md and the relevant reference/*.md page.