How to Configure Multiple OpenAI‑Compatible Providers in reasonix.toml
You configure multiple OpenAI‑compatible providers in reasonix.toml by defining separate [[providers]] array‑of‑tables for each vendor, specifying the name, base_url, api_key, and either model or models fields, then routing requests via provider/model syntax or the global default_model fallback.
The reasonix.toml file is the central configuration hub for the DeepSeek‑Reasonix inference engine, determining which LLM endpoints are available and how to authenticate against them. By leveraging TOML’s array‑of‑tables syntax, you can simultaneously register any number of OpenAI‑compatible services—such as OpenAI, Azure OpenAI, and Anthropic—within a single deployment. This guide explains the exact schema, source implementation, and routing logic used to direct requests to the correct vendor.
Understanding the reasonix.toml Provider Schema
Each provider is defined within a [[providers]] block, which supports the following fields:
name– Unique identifier used in theprovider/modelrouting syntax.base_url– The vendor’s API endpoint (e.g.,https://api.openai.com/v1).api_key– Authentication token for the vendor.model– Default model string for this provider when a specific model is not requested.models– Alternative tomodel; an array exposing multiple models under one provider name.supported_efforts– Optional list of effort levels (low,medium,high,max) the provider accepts. Defaults to all levels if omitted.disable_sampling– Boolean flag set totruefor vendors like Anthropic that rejecttemperatureortop_pparameters.
As implemented in sdk/go/provider.go, Reasonix parses these definitions at startup to build dedicated HTTP clients for each vendor.
Step‑by‑Step Configuration Guide
Follow these steps to register multiple providers:
- Copy the example file – Start with
reasonix.example.tomlfrom the repository root as a template. - Define the fallback – Set
default_modelat the top level, using either a plain model name orprovider/modelsyntax. - Add provider blocks – Append a
[[providers]]table for each vendor, ensuring each has a uniquename. - Configure capabilities – Set
supported_effortsanddisable_samplingto match the vendor’s API constraints. - Validate routing – Use
provider/modelin requests to test explicit routing, or omit the provider to test thedefault_modelfallback.
Complete Configuration Examples
OpenAI and Azure OpenAI Side‑by‑Side
This configuration registers both OpenAI and Azure endpoints, routing to Azure only when explicitly requested:
# reasonix.toml
default_model = "openai/gpt-4o-mini"
[[providers]]
name = "openai"
base_url = "https://api.openai.com/v1"
api_key = "sk-XXXXXXXXXXXXXXXXXXXXXXXX"
model = "gpt-4o-mini"
supported_efforts = ["low", "medium", "high", "max"]
[[providers]]
name = "azure"
base_url = "https://myresource.openai.azure.com/openai/deployments"
api_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
model = "gpt-4o-mini"
supported_efforts = ["low", "medium"]
disable_sampling = true
Requests resolve as follows:
model: "gpt-4o-mini"→ Routed to the OpenAI provider viadefault_model.model: "azure/gpt-4o-mini"→ Explicitly selects the Azure provider.
Integrating Anthropic Claude
Add a third provider for Claude, which requires sampling parameters to be disabled:
[[providers]]
name = "anthropic"
base_url = "https://api.anthropic.com/v1"
api_key = "YOUR_ANTHROPIC_API_KEY"
model = "claude-3-5-sonnet-20240620"
disable_sampling = true
supported_efforts = ["high", "max"]
Now model: "anthropic/claude-3-5-sonnet-20240620" routes to the Anthropic endpoint, as handled by the provider logic in internal/provider/anthropic.go.
Serving Multiple Models from One Provider
Expose several models under a single provider name using the models array:
[[providers]]
name = "openai"
base_url = "https://api.openai.com/v1"
api_key = "sk-..."
models = ["gpt-4o-mini", "gpt-4o"]
supported_efforts = ["low", "medium", "high", "max"]
Select specific models with openai/gpt-4o or openai/gpt-4o-mini. The implementation in internal/provider/openai.go maps these strings to the correct API calls.
Advanced Provider Settings
Configuring Effort Levels
The supported_efforts field controls which reasoning effort levels Reasonix advertises for a provider. If a vendor does not support the /effort endpoint, explicitly disable it:
[[providers]]
name = "legacy"
base_url = "https://legacy.example.com/v1"
api_key = "legacy-key"
model = "legacy-model"
supported_efforts = []
Disabling Sampling Parameters
For APIs that reject temperature or top_p, set disable_sampling = true. This prevents Reasonix from sending sampling parameters, adhering to the provider’s requirements as shown in internal/provider/anthropic.go.
How Reasonix Resolves Provider Routing
When Reasonix receives a request, it applies the following resolution logic, implemented in sdk/go/provider.go and internal/provider/openai.go:
- Parse the model string – If it contains a
/, split intoproviderandmodelcomponents. - Lookup provider – Match the
providercomponent against thenamefields in[[providers]]tables. - Fallback to default – If no
/is present, use thedefault_modelvalue, which may itself be aprovider/modelpair or a plain model name resolved against the default provider.
This routing system allows seamless switching between vendors without changing application code.
Summary
- Use separate
[[providers]]array‑of‑tables for each OpenAI‑compatible vendor, ensuring uniquenamevalues. - Set
default_modelat the root level to define the fallback when requests omit a provider prefix. - Route requests explicitly using
provider/modelsyntax (e.g.,azure/gpt-4o-mini). - Configure
supported_effortsanddisable_samplingto match vendor capabilities and avoid API errors. - Key source files governing this behavior include
reasonix.example.toml,sdk/go/provider.go, andinternal/provider/openai.go.
Frequently Asked Questions
How do I specify which provider to use in an API request?
Use the provider/model syntax in your request’s model field. For example, sending "anthropic/claude-3-5-sonnet-20240620" routes the request to the provider named anthropic defined in your reasonix.toml, while "openai/gpt-4o" routes to the openai provider.
What happens if I don't specify a provider in the request?
Reasonix falls back to the default_model value defined at the top of reasonix.toml. If default_model is set to "openai/gpt-4o-mini", all requests without an explicit provider prefix are routed to the openai provider using that model.
Can I disable temperature and top_p for specific providers?
Yes. Set disable_sampling = true inside the provider’s [[providers]] block. This is required for vendors like Anthropic Claude or certain Azure OpenAI configurations that reject sampling parameters, ensuring Reasonix omits temperature and top_p from the API call.
Where does Reasonix parse the provider configuration?
The Go SDK parses reasonix.toml in sdk/go/provider.go, which constructs HTTP clients for each defined provider. Provider‑specific logic, such as handling effort levels and model selection, is implemented in internal/provider/openai.go for OpenAI‑compatible APIs and internal/provider/anthropic.go for Claude‑specific adaptations.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →