Dograh

How to Use OpenRouter Models in a Voice Agent With Fallbacks

How to Use OpenRouter Models in a Voice Agent With Fallbacks
TutorialDecember 4, 2026·10 min read

How to Use OpenRouter Models in a Voice Agent With Fallbacks

Abhishek Kumar
Abhishek Kumar·Co-founder, Dograh AI

Co-founder of Dograh, building the future of open-source voice AI agents. Own your voice AI stack.

To use OpenRouter models in a voice agent, add your OpenRouter key as a provider, pick a tool-calling model slug and add a fallback. Each turn's text goes to OpenRouter and the model's host. For a full phone agent, Dograh, the open-source AI voice agent platform, takes OpenRouter as an LLM provider. Self-host it or run it on Dograh Cloud.

Key Takeaways

  • Set OpenRouter's privacy controls in your account before the first call.
  • Pick models by tool calls on spoken input, then pin a fast host.
  • Point Dograh's LLM fallback at a direct provider so one outage cannot stop both.

OpenRouter puts many model makers behind one key and one bill, which makes it easy to try models on a live agent. This guide adds OpenRouter to an agent in Dograh, our open-source platform, one step at a time, then covers speed, fallbacks and where the call text goes.

What you need before you start

These steps follow the published Dograh and OpenRouter docs. Use a test agent and a small credit balance until the trial calls pass, so a wrong model choice never reaches a real caller.

You need an OpenRouter account with an API key and some credits, and a Dograh agent that already works on another model. Dograh handles the call flow, the tools and the phone line, and the models sit in their own layer that you pick. OpenRouter fills only the language model slot here, so speech-to-text and the voice stay on the providers you already use.

OpenRouter sits between Dograh and the company that hosts the model. OpenRouter bills inference at the provider's list price on every plan, with a 5.5% fee when you buy credits on the Standard plan. Your model cost is therefore the host's price plus that fee, and per-token prices differ by model and host.

Step 1: Set privacy controls in OpenRouter first

Decide who may see the call text before the first call, because Dograh cannot set it per request. Each turn's text, the prompt, the transcript so far and any tool results, goes to OpenRouter and on to the company hosting the model. The language model gets text, not audio, and the caller's audio goes only to your speech-to-text provider.

OpenRouter works with providers so prompts are not trained on wherever possible, but there are exceptions. In your account settings you can block providers that may train on your data, with separate settings for paid and free models, and limit routing to hosts with zero data retention. OpenRouter's routing does not change on its own based on a host's retention policy, so these settings are where you make that choice.

Dograh sends OpenRouter only the model and your provider order, not the privacy fields, so the account settings apply to every call. On the Business and Enterprise plans, OpenRouter can process requests in the EU or the US when they go to its regional address, eu.openrouter.ai or us.openrouter.ai, which you set as the Base URL in Step 3.

Check: your OpenRouter account shows the provider and retention settings you chose, and the key you will use belongs to that account.

Step 2: Add OpenRouter under Providers

The key goes into Dograh once, as a provider connection. Open Providers in the sidebar and choose Add Provider. Pick Open Router as the Provider, give it a Connection name such as "OpenRouter production", paste your key under Credentials and choose Save Connection. The provider connections page covers the editor in full.

Dograh saves an OpenRouter key without sending a live request to OpenRouter, so a typo is not caught at save time. Make a test call right after adding the key, since that is the first real request to OpenRouter.

For how keys, managed models and billing fit together in general, see our post on BYOK vs managed models. This post covers only the OpenRouter fields.

Check: the OpenRouter connection appears on the Providers page under the name you gave it.

Step 3: Create a model configuration for it

A named model configuration ties the OpenRouter connection to a model and its settings. Open Models in the sidebar, choose Add Configuration, give it a Configuration name and pick BYOK mode. On the LLM tab, select your OpenRouter connection, then fill in the LLM fields.

Model takes an OpenRouter slug in "vendor/model" form, such as openai/gpt-4.1, which is also the default. The dropdown offers a short preset list plus Enter Custom Value, and the presets are older models, so type the current slug from the model's OpenRouter page. Temperature starts at 0.1, which keeps tool calls steady. Leave the Base URL at https://openrouter.ai/api/v1 unless you use a regional address or proxy OpenRouter through your own gateway, and leave Provider order empty for now, since Step 5 sets it.

Then choose who uses it. Click Make org default on its row if every agent should inherit it, or open one agent's Model tab, choose Preset configuration and pick it under Configuration. Test calls use the new setting at once, and live calls use it after you publish the agent.

Check: a browser test call on the agent answers normally, and the run's trace shows the OpenRouter model slug.

Dograh

Open Source Alternative to Vapi / Retell

Self-hosted voice agent platform — no per-minute fees

dograh-hq/dograh

Star on GitHub

Step 4: Choose a model that calls your tools

A voice agent lives on its tool calls, so test those first and speed second. OpenRouter lists only the models that support tools when you filter its model list with supported_parameters=tools, and its tool format follows OpenAI's function calling. A model missing from that list cannot drive an HTTP API tool.

From that list, keep the models that call the right tool with the right values on spoken input, such as a ZIP code said with a pause in the middle. Our post on choosing an LLM for voice agents gives a short test for this, so run it on two or three slugs rather than trusting a leaderboard.

Avoid letting OpenRouter pick the model for you on a voice agent. Its Auto Router, openrouter/auto, chooses a model per request, so the agent you tested may not be the agent that answers the next call. In our view a phone agent should run one slug you have tested.

Check: the chosen slug calls each of the agent's tools correctly in three browser test calls.

Step 5: Pin fast hosts with Provider order

Many models on OpenRouter are served by several hosts at different speeds. By default OpenRouter picks a host by comparing what a good response would cost at each one, weighing price, throughput, first-token time, rate limits and reliability. For a phone call you usually want speed first.

Provider order changes that. Enter the host slugs to try first, one per entry, as listed on the model's OpenRouter page, for example groq for a model Groq serves. Dograh sends them as OpenRouter's provider.order and nothing else. OpenRouter keeps allow_fallbacks on by default, so if your pinned hosts are down, other hosts still serve the call.

That gives you a first layer of backup inside OpenRouter, for the same model. It does not help when OpenRouter itself is slow or your credits run out, which Step 7 covers.

Check: after a test call, the request in your OpenRouter activity log shows the host you pinned.

Step 6: Measure the delay on real calls

Speed numbers from a model page tell you little about your own calls, so measure. Twilio's latency guide defines a turn's delay as the time from when the caller stops speaking to when the reply reaches their ear. As of November 2025 it sets 1,115 ms as a starting target for that whole gap and 375 ms for the model's time to first token.

Make a browser test call first, then a real phone call, and open View Trace on each run. The trace shows the speech-to-text, model and voice time for each turn, so you can see the model's share on its own. Look at tool-call turns separately, because a tool call adds a second model round trip and runs longer than a plain reply.

If the model's share is the slow part, try a smaller slug of the same family or trim the prompt, since every turn sends the prompt and the transcript so far again. Change one thing at a time, the slug or the Provider order, and compare the same script before and after. Our post on the best LLMs for voice agents by latency explains how to read first-token time on your own calls. If a direct connection to the same model's host is faster on your calls, keep that as the fallback in Step 7.

Check: you have model times per turn for at least five phone calls on each setup you compared.

Join the Dograh Community

Dograh is an OSS alternative to Vapi. Join our Slack community for queries, releases, best practices & community interactions.

Step 7: Add fallbacks for slow or failed requests

The second layer of backup sits in Dograh and can leave OpenRouter entirely. On the model configuration, choose Configure fallbacks to open LLM fallbacks. It has two rules, Slow response and Request error, and each points at a Provider connection that must differ from the primary in connection or model.

Inside the OpenRouter cloud, three hosts serve the same model. The pinned host is crossed out and an arrow passes the request to another host. Below the cloud, an orange cable labeled LLM fallbacks, in Dograh runs from the AI agent straight to a direct provider, the model maker's own API.
Backup hosts inside one gateway still depend on that gateway being up and paid for. A second route that skips it keeps a waiting caller answered, though that provider then receives the conversation as well.

Slow response starts the backup if the primary has not produced answer text or a tool call within your limit, set in Wait before starting fallback (ms). It starts at 1,500 ms and accepts 100 to 10,000. Request error starts the backup on any error before output, including rate limits, billing errors, connection failures and empty responses. Both act only before the answer or a tool call begins.

Point both rules at a direct provider connection, such as the model maker's own API, so an OpenRouter outage or an empty credit balance does not take out the primary and the backup together. A backup request sends the conversation to that provider too, so it needs the same privacy review as Step 1. Our post on using different models in one voice agent covers per-call model changes as well.

Check: with the OpenRouter key revoked on a test connection, a test call still answers through the backup.

Before you ship it

Run the full setup on the trial agent before any real number points at it. Confirm the privacy settings in OpenRouter, a test call on the configuration, tool calls on spoken input, the pinned host in OpenRouter's log and a working fallback. Then publish the agent so live calls use the new configuration.

Keep the data path in mind when you choose where to run. When you self-host Dograh, recordings and transcripts stay on your servers, while each turn's text still leaves for OpenRouter and the model's host. A key of your own puts the contract between you and OpenRouter, and it does not keep that text in-house. Self-hosting has no per-minute platform fee, but servers, model keys and phone minutes still cost money, and here the model line is your OpenRouter bill. Dograh Cloud charges a 1¢-a-minute platform fee.

Glossary

Model slug
OpenRouter's name for a model in vendor/model form, such as openai/gpt-4.1. Dograh's Model field takes it as typed.
Provider order
The list of OpenRouter host slugs to try first for a model. Dograh sends it as provider.order, and other hosts still serve the call if those are down.
Zero data retention
A host setting where prompts and replies are not stored after the request. OpenRouter lets an account route only to such hosts.
Slow response fallback
A Dograh rule that starts a backup LLM when the primary gives no answer text or tool call within a set wait, 1,500 ms by default.

Frequently Asked Questions

Get started with Dograh

Build, deploy, and scale AI agents with Dograh. Join the community of developers building the future.