| Approach | Best for |
|---|---|
| API | Full control, any language, no dependencies |
| Client SDKs | Type-safe model calls with minimal overhead |
| Agent SDK | Building agents with tool use, loops, and state |
Using the OpenRouter API
The most direct way to use OpenRouter. Send standard HTTP requests to the/api/v1/chat/completions endpoint — compatible with any language or framework.
The examples below use
~openai/gpt-latest, a latest alias that always resolves to the newest OpenAI flagship model — so your code keeps using the freshest version without redeploying. You can substitute any model slug here. Browse the full catalog at openrouter.ai/models, or list every available slug programmatically via the GET /api/v1/models endpoint.Using the Client SDKs
The Client SDKs wrap the OpenRouter API with full type safety, auto-generated types from the OpenAPI spec, and zero boilerplate. It is intentionally lean — a thin layer over the REST API. First, install the SDK:Using the Agent SDK
The Agent SDK (@openrouter/agent) provides higher-level primitives for building AI agents. It handles multi-turn conversation loops, tool execution, and state management automatically via the callModel function.
Install the package:
get_weather, feeds the result back, and returns the final response — all in one callModel invocation.
See the full Agent SDK documentation for stop conditions, streaming, dynamic parameters, and more.