How to integrate Openrouter MCP with Codex

Connect Codex to Openrouter MCP. Generate python code from this prompt, summarize this article using claude-3, and more using natural language, with authentication handled for you.

Openrouter logoOpenrouter
Api Key

OpenRouter is a unified API platform for accessing language models from various providers. It lets you easily integrate and switch between multiple LLMs with a single API.

122 Tools

Introduction

Codex is one of the most popular coding harnesses out there. And MCP makes the experience even better. With the Openrouter MCP integration, Codex can chat with models from many providers, create embeddings, generate speech and video, rerank content, and check your credits, all without leaving the terminal or the app, whichever you prefer.

Also integrate Openrouter with

Why use Composio?

Apart from a managed and hosted MCP server, you will get:

  • CodeAct: A dedicated workbench that allows GPT to write its code to handle complex tool chaining. Reduces to-and-fro with LLMs for frequent tool calling.
  • Large tool responses: Handle them to minimise context rot.
  • Dynamic just-in-time access to 20,000 tools across 1700+ other Apps for cross-app workflows. It loads the tools you need, so GPTs aren't overwhelmed by tools you don't need.

How to install Openrouter MCP in Codex

Run the setup command

Run this command in your terminal to add the Composio MCP server to Codex.

Terminal

It will initiate the authentication in a browser window, authorize Codex to access your Composio account.

Composio authentication page

(Optional) Authenticate with OAuth

To authenticate manually, run the login command to open a browser window and authorize Codex to access your Composio account.

bash
codex mcp login composio

Verify the connection

Run codex mcp list to confirm Composio appears as a registered MCP server.

bash
codex mcp list

Codex App

Codex App follows the same approach as VS Code.

  1. Click ⚙️ on the bottom left → MCP Servers → + Add servers → Streamable HTTP:
  2. Fill the header and Key fields with { "x-consumer-api-key" = "ck_*******" }.
  3. The Key is the Composio API key, that you can find on dashboard.composio.dev
  4. Click on Authenticate and authorize Codex to your Composio account and you're all set.
Codex App MCP setup
  1. Restart and verify if it's there in .codex/config.toml
bash
[mcp_servers.composio]
url = "https://connect.composio.dev/mcp"
http_headers = { "x-consumer-api-key" = "ck_*******" }

Try it

Ask Codex for a Openrouter task. The first time, Composio asks you to connect your Openrouter account.

For example, ask it to:

  • "Generate Python code from this prompt"
  • "Summarize this article using Claude-3"
  • "List all available Llama-3 model endpoints"

What is the Openrouter MCP server, and what's possible with it?

The Openrouter MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Openrouter account. It provides structured and secure access to a wide range of large language models, so your agent can generate completions, manage model access, check credits, and retrieve generation details seamlessly on your behalf.

  • Unified model completions: Let your agent generate chat-based or text completions using any model available through Openrouter, perfect for conversation or content creation tasks.
  • Model catalog and provider discovery: Ask your agent to list all available AI models and providers, helping you compare capabilities, endpoints, and pricing in real time.
  • Credit monitoring and usage tracking: Have your agent fetch your current API credit balance, so you always know your usage limits before starting new tasks.
  • Generation result retrieval: Direct your agent to pull detailed metadata for any previous generation, including token counts, costs, and latency for analysis or auditing.
  • Endpoint and configuration info: Empower your agent to fetch the latest model endpoints and supported parameters, making it easy to fine-tune routing and optimize performance.

Conclusion

You've successfully integrated Openrouter with Codex using Composio's MCP server. Now you can interact with Openrouter directly from your terminal, VS Code, or the Codex App using natural language commands.

Key benefits of this setup:

  • Seamless integration across CLI, VS Code, and standalone app
  • Natural language commands for Openrouter operations
  • Managed authentication through Composio
  • Access to 20,000+ tools across 1700+ apps for cross-app workflows
  • CodeAct workbench for complex tool chaining

Next steps:

  • Try asking Codex to perform various Openrouter operations
  • Explore cross-app workflows by connecting more toolkits
  • Build automation scripts that leverage Codex's AI capabilities
TOOLS

Supported Tools

Every Openrouter action and event your agent gets out of the box.

Activate a validated private endpoint

Make a validated draft routable.

Bulk add members to a workspace

Add multiple organization members to a workspace.

Bulk assign keys to a guardrail

Assign multiple API keys to a specific guardrail.

Bulk assign members to a guardrail

Assign multiple organization members to a specific guardrail.

Bulk remove members from a workspace

Remove multiple members from a workspace.

Bulk unassign keys from a guardrail

Unassign multiple API keys from a specific guardrail.

Bulk unassign members from a guardrail

Unassign multiple organization members from a specific guardrail.

Create a new API key

Create a new API key for the authenticated user.

Create authorization code

Create an authorization code for the PKCE flow to generate a user-controlled API key

Create a batch

Creates a batch of requests that run asynchronously against a single endpoint (`/v1/chat/completions`, `/v1/responses`, `/v1/messages`, `/v1/embeddings`).

Create a BYOK provider credential

Create a new bring-your-own-key (BYOK) provider credential.

Create Chat Completion

Generate a chat-style completion from messages and a selected model, with function-call request options.

Create Coinbase Charge

Tool to create a Coinbase charge for crypto payment to add credits to your OpenRouter account.

Create Embeddings

Create vector embeddings for text, token, or multimodal inputs.

Create a guardrail

Create a new guardrail for the authenticated user.

Create Message (Anthropic Format)

Create a message using Anthropic Messages API format via OpenRouter, with text, image, PDF, tool, and extended-thinking request options.

Create an observability destination

Create a new observability destination.

Create a preset from a chat-completions request body

Creates a preset (or a new version of an existing one) from an inference request body.

Create a preset from a messages request body

Creates a preset (or a new version of an existing one) from an inference request body.

Create a preset from a responses request body

Creates a preset (or a new version of an existing one) from an inference request body.

Create a private endpoint

Create a private endpoint as a draft.

Create a SCIM group mapping

Create a SCIM group-to-workspace role mapping.

Start a SCIM directory sync

Start a SCIM directory sync.

Create Speech

Synthesize speech from text or multi-speaker turns.

Create Transcription

Transcribe audio into text using an OpenRouter speech-to-text model.

Create Video Generation

Submit an asynchronous video generation job to OpenRouter.

Create a workspace

Create a new workspace for the authenticated user.

Delete an API key

Delete one of the authenticated account's own API keys, revoking the selected key's access.

Delete a batch

Deletes a batch in a terminal status (`completed`, `failed`, `expired`, or `cancelled`) and its stored requests and results.

Delete a BYOK provider credential

Delete (soft-delete) a bring-your-own-key (BYOK) provider credential by its `id`.

Delete a file

Deletes a file owned by the requesting workspace.

Delete a guardrail

Delete an existing guardrail.

Delete an observability destination

Delete an existing observability destination.

Delete a private endpoint

Delete a private endpoint and stop routing to it.

Delete a SCIM group mapping

Delete a SCIM group-to-workspace mapping.

Delete a workspace

Delete an existing workspace.

Delete a workspace budget

Remove the budget for a given interval.

Disable a private endpoint

Stop routing to an active endpoint without deleting it.

Download Container File Content

Download raw file content from an OpenRouter container using its canonical container and file IDs.

Download File Content

Download raw content of a server-created file.

Enable a private endpoint

Resume routing to a disabled endpoint.

Exchange authorization code for API key

Exchange an authorization code from the PKCE flow for a user-controlled API key

Exchange a workload identity token

RFC 8693 token exchange.

Generate an image

Generates an image from a text prompt via the image generation router

Get available analytics metrics and dimensions

Returns the available metrics, dimensions, filter operators, and granularities for the analytics query endpoint.

Get a single API key

Get a single API key by hash.

Top apps by token usage

Returns the top public apps on OpenRouter ranked by token usage inside the requested date window, matching the public apps marketplace on openrouter.

Get a batch

Returns a batch with its status and request counts.

List Benchmarks

Unified benchmark endpoint that aggregates scores from multiple benchmark sources (Artificial Analysis, Design Arena, and OpenRouter's own tau-bench, GPQA, and web-search evals).

Get a BYOK provider credential

Get a single bring-your-own-key (BYOK) provider credential by its `id`.

Retrieve a container file

Returns the metadata of a single file in a container.

Get Credits

Tool to get the current API credit balance for the authenticated user.

Get Current Key

Tool to get information about the currently authenticated API key.

Get file metadata

Retrieves metadata for a single file owned by the requesting workspace.

Get Generation

Tool to retrieve a generation result by its unique ID.

Get a guardrail

Get a single guardrail by ID.

Get a model by its slug

Returns full details for a single model identified by its author and slug (e.

Get Models Count

Tool to get the total count of available models on OpenRouter.

OpenRouter access token signing keys

RFC 7517 JWK Set containing the public keys OpenRouter signs access tokens with.

Get an observability destination

Fetch a single observability destination by its UUID.

Get organization settings

Get the settings of the organization associated with the authenticated management key.

Get a preset

Retrieves a preset by its slug with its currently designated version inline.

Get a specific version of a preset

Retrieves a specific version of a preset by its slug and version number.

Get a private endpoint

Get one private endpoint with its upstream configuration and current pricing.

Daily token totals for top 50 models

Returns the top 50 public models per day by total token usage on OpenRouter, plus a single aggregated `other` row per day that sums every model outside that top 50.

Get a SCIM group mapping

Get a SCIM group-to-workspace mapping.

Get SCIM directory sync status

Get SCIM directory sync status.

Cost per session by harness and model

Returns weekly refreshed, aggregated cost-per-session cells for the published harnesses.

Task classification market share

Returns the market-share breakdown of OpenRouter traffic by task classification (e.

Get a server tool

One server tool by canonical name or any accepted alias, with the models that run it natively.

Get user activity grouped by endpoint

Returns user activity data grouped by endpoint for the last 30 (completed) UTC days.

Get Video Content

Download one output from a completed OpenRouter video generation job.

Get Video Generation

Poll a video generation job for its status, outputs, and usage.

Get a workspace

Get a single workspace by ID or slug.

Get a workspace budget

Retrieve the budget for a given interval.

List API keys

List all API keys for the authenticated user.

List Available Models

List available OpenRouter models, optionally filtered by category.

List batches

Lists batches in the workspace of the authenticating API key, newest first.

List BYOK provider credentials

List the bring-your-own-key (BYOK) provider credentials for the authenticated entity's default workspace.

List container files

Lists the files in a container, in lexicographic path order.

List Embedding Models

List available OpenRouter embedding models with properties including architecture, pricing, and capabilities.

List files

Lists files belonging to the workspace of the authenticating API key.

Get stored prompt, completion, and error content for a generation

Get stored prompt, completion, and error content for a generation

List key assignments for a guardrail

List all API key assignments for a specific guardrail.

List member assignments for a guardrail

List all organization member assignments for a specific guardrail.

List guardrails

List all guardrails for the authenticated user.

List endpoints for an image model

Returns the full per-endpoint records for an image model: each endpoint's definitive supported parameters, pricing, and passthrough allowlist.

List image generation models

Lists every image generation model with its top-level supported-parameter superset and a URL to its full per-endpoint records.

List all key assignments

List all API key guardrail assignments for the authenticated user.

List all member assignments

List all organization member guardrail assignments for the authenticated user.

OpenRouter List Model Endpoints

Tool to list endpoints for a specific model.

List observability destinations

List the observability destinations configured for the authenticated entity's default workspace.

List organization members

List all members of the organization associated with the authenticated management key.

List presets

Lists all presets for the authenticated user, ordered by most recently updated first.

List versions of a preset

Lists all versions of a preset, ordered by version number ascending (oldest first).

List private endpoints

List the organization's private endpoints, including drafts.

OpenRouter List Providers

Tool to list all AI model providers available through the OpenRouter API.

List SCIM group mappings

List SCIM group-to-workspace mappings for the organization.

List SCIM groups

List SCIM groups for the organization.

List server tools

Lists every server tool OpenRouter can run on behalf of a model: accepted `tools[].

List User Models

List models filtered by user provider preferences, privacy settings, and guardrails.

List Video Models

List video generation models and their supported capabilities.

List workspace budgets

List all budgets configured for a workspace.

List workspace members

List all members of a workspace.

List workspaces

List all workspaces for the authenticated user.

OpenRouter List ZDR Endpoints

Tool to preview the impact of Zero Data Retention (ZDR) on the available endpoints.

Promote a container file into workspace documents

Copies a file from the container's sandbox prefix into the workspace's durable document storage, so it outlives the container.

Query analytics data

Execute an analytics query with specified metrics, dimensions, filters, and time range.

Rerank Content

Rank text or multimodal documents by relevance to a query.

Submit feedback for a generation

Submit structured feedback on a generation the authenticated user made.

Submit a System One request

Sends state and typed questions to a System One model such as Jev and returns its answers.

Update an API key

Update one of the authenticated account's own API keys.

Update a BYOK provider credential

Update an existing bring-your-own-key (BYOK) provider credential by its `id`.

Update a guardrail

Update an existing guardrail, or materialize an unconfigured workspace default guardrail.

Update an observability destination

Update an existing observability destination.

Update organization settings

Update the settings of the organization associated with the authenticated management key.

Update a private endpoint

Change any of the endpoint fields you own in one call; only the fields present change, and the response is the whole endpoint.

Update a SCIM group mapping

Update a SCIM group mapping role.

Update a workspace

Update an existing workspace by ID or slug.

Upload File

Upload a file for future API calls under the authenticating key's workspace.

Create or update a workspace budget

Create or update the budget for a given interval.

Validate a draft private endpoint

Send a live test request to the draft endpoint using the given workspace's BYOK credential for its provider.

FAQ

Frequently asked questions

With a standalone Openrouter MCP server, the agents and LLMs can only access a fixed set of Openrouter tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Openrouter and many other apps based on the task at hand, all through a single MCP endpoint.

Yes, you can. Codex fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Openrouter tools.

Yes, absolutely. You can configure which Openrouter scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Openrouter data and credentials are handled as safely as possible.

Start with Openrouter.It takes 30 seconds.

Managed auth, hosted MCP servers, and every Openrouter tool your agent needs.Free to start.

Start building