OpenRouter is now a native provider — you no longer need to set it up as an OpenAI-compatible custom provider. The legacy custom provider approach still works, but the native integration is recommended because it uses the official OpenRouter SDK and unlocks image, video, and speech capabilities.
Configuring your OpenRouter API key
- Get an OpenRouter API key: Sign up at OpenRouter and create a key in their dashboard.
- In your PromptLayer workspace settings, open the provider API keys section and add your OpenRouter key (the same place you add OpenAI, Anthropic, or Google keys).
When you run through the SDK with
promptlayer.run(), the OpenRouter call is executed locally with the OPENROUTER_API_KEY on your machine — your provider key is never sent to PromptLayer.Capabilities
OpenRouter models in PromptLayer are grouped by API type. When you select OpenRouter in the Playground, an API selector lets you switch between the capabilities below, and the model dropdown lists only the models that support the selected one.
Additional chat features are supported per model, gated by OpenRouter’s model metadata:
- Streaming — token-by-token streaming for chat.
- Structured outputs — JSON Schema
response_formaton models that advertise support. - Function / tool calling — your Prompt Registry tools map to OpenRouter
tools. - Server (built-in) tools — OpenRouter server tools such as web search are available in the Functions editor as built-in tools for OpenRouter models. See Tool Calling.
Using OpenRouter in the Playground
- Open the Playground.
- Select OpenRouter from the provider dropdown.
- Choose the API type (Chat, Images, Video, or Speech).
- Pick a model from the dropdown.
- For Speech, choose a voice and response format in the model controls.
- Run your prompt. Chat streams live; image, video, and speech return the generated media inline (audio plays with a built-in player).
Speech (text-to-speech)
Speech models take the prompt text as the input to synthesize and require a voice parameter. The voice dropdown for each model is populated from that model’s own OpenRouter-advertised voice list, sorted alphabetically. The response is returned as playable audio and logged as an audio output.SDK usage
Once you’ve configured your OpenRouter key and created a prompt template that uses an OpenRouter model, run it with the PromptLayer SDK. The API type (chat / images / video / speech) is derived from the template’s model configuration, so the samerun() call works for every capability.
Using
promptlayer.run() ensures your requests are logged to PromptLayer and uses your Prompt Registry templates. This is the recommended approach for production.
