Skip to main content
Interact with OpenRouter models using the OpenAI Responses API. OpenRouter’s Responses API (currently in beta) provides OpenAI-compatible access to multiple AI models through a unified interface.

Requirements

Set the OPENROUTER_API_KEY environment variable:

Key Features

  • Unified Interface: Access multiple AI providers through a single API
  • Fallback Model Routing: Automatically try alternative models if the primary fails
  • Stateless API: Each request is independent (no server-side state persisted)
  • Reasoning Support: Enable reasoning for supported models

Parameters

Usage

Basic Usage

With Reasoning

Fallback Model Routing

If the primary model fails due to rate limits, timeouts, or unavailability, OpenRouter automatically tries the fallback models in order:

Developer Resources