Skip to main content
Use /v1 for your default router. For a specific router, send the same body to https://routing.dari.dev/{router_id}/chat/completions. The response follows the OpenAI Chat Completions format and adds dari_routing, which identifies the selected model and reasoning effort.

Streaming

Set stream: true. Dari returns Server-Sent Events in the OpenAI stream format, with dari_routing in the first event and data: [DONE] at the end.

Tool Calls

Send standard OpenAI tools and tool_choice fields. If the selected model calls a tool, append the result as a tool message and send the complete message history again.

Conversations and Leases

The router groups requests into conversations and remembers which model served earlier turns. A routing policy can keep later turns on that model for a few turns. This is a lease. Send the same identity on every turn of one conversation, using either:
  • the x-session-affinity header, or
  • the prompt_cache_key body field.
If you send both, the header wins. Use a unique value for each run or session. Two runs that send the same value share one conversation, so one can inherit the other’s routing state. If you send neither, the router matches each request’s message history against earlier requests:
  • Identical runs, such as retries of the same task, can match each other. The most recently active run wins.
  • Rewriting earlier messages starts a new conversation.
  • Compaction that keeps earlier messages intact stays in the same conversation. The conversation is keyed on the system and tools head plus the message prefix.
  • Lease position counts the assistant messages in each request. Removing assistant turns moves when the next routing decision happens.
See the Chat Completions API Reference for supported fields.