Providers
A provider in kanros is anything that turns a CompletionRequest into a
CompletionResponse. The trait lives in kanros-core::provider::Provider
and is implemented once per backend in a dedicated crate under
crates/kanros-providers/.
Providers are referenced in config by id, in family:model form:
providers:
- id: openai:gpt-4o-mini
- id: anthropic:claude-3-5-haiku
- id: ollama:llama3.1
The segment before the colon (openai, anthropic, ollama, …) is the
provider family; it selects which crate handles the request. The
segment after the colon is forwarded verbatim as the model id.
Bundled provider families
The workspace currently ships the following provider crates. Every name
below corresponds to a directory in crates/kanros-providers/ and to a
provider family id.
| Family | Crate | Notes |
|---|---|---|
echo | kanros-provider-echo | Identity provider — returns the rendered prompt. |
openai | kanros-provider-openai | OpenAI chat completions + embeddings + moderation. |
anthropic | kanros-provider-anthropic | Claude chat completions. |
azure-openai | kanros-provider-azure-openai | Azure OpenAI Service. |
ollama | kanros-provider-ollama | Local Ollama daemon. |
http | kanros-provider-http | Generic HTTP provider with templated request/response. |
llama-cpp | kanros-provider-llama-cpp | llama.cpp server protocol. |
lm-studio | kanros-provider-lm-studio | LM Studio local server. |
subprocess | kanros-provider-subprocess | Spawn an arbitrary subprocess and pipe stdin/stdout. |
bedrock | kanros-provider-bedrock | Amazon Bedrock. |
browser | kanros-provider-browser | Chromium via CDP — for E2E flows. |
cloudflare | kanros-provider-cloudflare | Cloudflare Workers AI. |
cohere | kanros-provider-cohere | Cohere Command and embeddings. |
deepseek | kanros-provider-deepseek | DeepSeek API. |
fireworks | kanros-provider-fireworks | Fireworks AI. |
groq | kanros-provider-groq | Groq inference. |
huggingface | kanros-provider-huggingface | Hugging Face Inference API. |
mistral | kanros-provider-mistral | Mistral AI. |
openrouter | kanros-provider-openrouter | OpenRouter (routes to many backends). |
perplexity | kanros-provider-perplexity | Perplexity online models. |
replicate | kanros-provider-replicate | Replicate. |
together | kanros-provider-together | Together AI. |
voyage | kanros-provider-voyage | Voyage embeddings + reranker. |
vertex | kanros-provider-vertex | Google Vertex AI / Gemini. |
vllm | kanros-provider-vllm | vLLM OpenAI-compatible server. |
websocket | kanros-provider-websocket | Bidirectional WebSocket provider. |
xai | kanros-provider-xai | xAI Grok. |
Inline provider config
Per-provider configuration is forwarded as a JSON value:
providers:
- id: openai:gpt-4o-mini
config:
temperature: 0.0
max_tokens: 512
top_p: 0.9
- id: ollama:llama3.1
config:
endpoint: "http://localhost:11434"
The config block is provider-specific. Each provider crate documents its
own keys in its README; the OpenAI family, for instance, accepts the
usual temperature, top_p, max_tokens, seed, plus an endpoint
override for proxies.
Credentials
For network providers, kanros looks for an API key in this order:
config.api_keyin the provider's inline config block (not recommended for source control).- The provider-specific environment variable (e.g.
OPENAI_API_KEY,ANTHROPIC_API_KEY,GROQ_API_KEY). - The system keyring (see
kanros auth), under the service namekanrosand account name equal to the provider family.
If none of the three resolve, the provider returns an error and the cell
exits with the provider_error field set. The whole run exits with code
3.
Adding a provider
Each provider is a small crate that implements
kanros_core::provider::Provider:
use async_trait::async_trait;
use kanros_core::{CompletionRequest, CompletionResponse, Provider, ProviderError};
#[derive(Debug)]
struct MyProvider { /* … */ }
#[async_trait]
impl Provider for MyProvider {
fn id(&self) -> &str { "myprovider:demo" }
async fn complete(&self, req: CompletionRequest) -> Result<CompletionResponse, ProviderError> {
// …
todo!()
}
}
Register the provider with the kanros-providers registry (see
crates/kanros-providers/src/lib.rs). Once registered, users can refer to
it by id from any kanros config.
The echo provider
The echo:identity provider is special: it returns the rendered prompt
verbatim. It has no dependencies, no I/O, and no per-call cost. It is the
right pick for smoke tests, schema fixtures, and CI bootstraps.
providers:
- id: echo:identity
prompts:
- "say {{ word }}"
tests:
- vars: { word: hello }
assert:
- type: contains
value: hello