Read github.com/OpenRouterTeam/skills/tree/main/skills/create-agent-tui and follow the instructions to build an agent using OpenRouter.
Using the OpenRouter API
The most direct way to use OpenRouter. Send standard HTTP requests to the/api/v1/responses endpoint. It works with any language or framework.
The examples below use
~openai/gpt-sol-latest, a latest alias that always resolves to the newest model in the OpenAI GPT Sol family, 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.Output
For EU in-region routing on Business or Enterprise, send requests to
https://eu.openrouter.ai/api/v1/responses, or set your SDK’s base URL to https://eu.openrouter.ai/api/v1, with an EU-eligible model. EU in-region routing on Business explains what is processed in Europe, what may be stored or processed in the US, and how BYOK requests are handled.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’s intentionally lean, a thin layer over the REST API. First, install the SDK:Output
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:
Output
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.
Using the OpenAI SDK
You can also use the OpenAI SDK pointed at OpenRouter as a drop-in replacement. This is useful if you have existing code built on the OpenAI SDK and want to access OpenRouter’s model catalog without changing your code structure.Output