LlamaIndex

Plug OneRouter into LlamaIndex with the OpenAI-compatible client.

Prepare the connection

Create a dedicated OneRouter API key, then choose a complete model ID from the Models page or GET /v1/models. Keep the key in an environment variable or the application's protected credential store.

curl https://onerouter.com/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY"

Configuration

from llama_index.llms.openai_like import OpenAILike

llm = OpenAILike(
    api_base="https://onerouter.com/v1",
    api_key="YOUR_API_KEY",
    model="openai/gpt-5.2",
    is_chat_model=True,
)

Verify

Save the configuration, fully restart the app or terminal session, and select the saved OneRouter provider. Send a small test request such as Reply with OK only, then confirm it appears in OneRouter usage logs before enabling tools, file access, or production traffic.

Troubleshooting

SymptomHow to fix it
401Re-enter the complete key and confirm the restarted process can read it.
403Confirm the key can access the requested model.
404Use https://onerouter.com/v1 as the OpenAI-compatible base URL; do not append a request path unless the client asks for a full endpoint.
Model not foundUse the complete ID returned by GET /v1/models, including the provider prefix.
Saved settings have no effectRestart the whole application and check whether workspace-level settings override the user configuration.