Connect your key to the client that will use it
For Codex, configure a named provider with its endpoint and the environment variable holding your gateway key. For Cursor, start in Settings → Models and choose the provider supported by your installation. One TrustedRouter key works in both, and in Claude Code and OpenCode. Give each agent its own key with a spend limit.
Try one small task before moving a project. Ask the agent to read a fixture and report its first field. Check that the chosen model answered and that the tool result came back into the conversation. That gives you a working reference when you later change providers, keys or models.
Codex API key and custom provider configuration
Codex supports custom provider configuration. The example below selects a Responses-compatible gateway and reads the credential from the environment. Swap in any model ID from the catalog, and merge the settings into your existing configuration.
model = "deepseek/deepseek-v4.1-flash"
model_provider = "trustedrouter"
[model_providers.trustedrouter]
name = "TrustedRouter"
base_url = "https://api.trustedrouter.com/v1"
env_key = "TRUSTEDROUTER_API_KEY"
wire_api = "responses"Check the official Codex configuration reference for your version. This setup works with the chat models in our catalog, so you can try DeepSeek, Claude or Kimi in Codex. Test the agent features you rely on before migrating.
Codex with OpenRouter or another gateway
Use a separate provider name for each connection, and pair its base URL with the corresponding credential. Each gateway issues its own key. Compare the same task and explicit model ID where both catalogs offer it; preserve the working configuration until the new route passes your checks.
Our gateway comparison covers the broader choice. Use cost per accepted patch to assess value rather than comparing one input-token price.
Cursor API keys and custom endpoint limits
Cursor documents key setup under Settings → Models. Its API key guide says custom keys cover chat models, while Tab completion keeps using Cursor's built-in models. It also explains that requests pass through Cursor's backend for prompt construction and that its own ZDR policy does not apply to BYOK traffic.
For Cursor with OpenRouter, DeepSeek or TrustedRouter, confirm that your installed version exposes a suitable custom endpoint and supports the model's request format. If your Cursor version can't connect to the model you want, OpenCode can: run /connect, pick TrustedRouter, then run /models.
Verify before moving your real project
| Check | Why it matters |
|---|---|
| Credential and base URL | Prevents sending a key to the wrong service. |
| Model ID and API format | Makes sure the client and model use the same API format. |
| Streaming and tool round trip | Shows the agent can use tools, not just chat. |
| Cost and limits | App charges and model-provider charges may be separate. |
| Editor, gateway and upstream privacy | Your editor, the gateway and the model provider all see your code, so choose providers that meet your privacy needs. |
Start with a non-sensitive test project, confirm a small edit and run its tests. Keep secrets in the supported credential store or environment. For Claude Code, use the dedicated Messages gateway guide; for common endpoints and smoke tests, see agent setup.
Documentation reviewed November 20, 2026.