Set up OpenAI, Anthropic, Gemini, and Ollama
Install the runtime and one provider adapter, configure native or compatible clients, keep credentials server-side, and verify exact model capabilities.
Install one provider
Runifold 0.9 keeps concrete adapters in runifold-providers. Add the runtime
facade and enable only the adapter your application deploys:
cargo add runifold@0.9.0
cargo add runifold-providers@0.9.0 --features openai
cargo add tokio --features macros,rt-multi-threadReplace openai with anthropic, gemini, ollama, or bedrock. Named
OpenAI-compatible modules such as DeepSeek, Ark, Groq and OpenRouter share the
single openai protocol Feature instead of adding facade Features.
| Provider | Feature | Credential or endpoint |
|---|---|---|
| OpenAI | openai | OPENAI_API_KEY |
| Anthropic | anthropic | ANTHROPIC_API_KEY |
| Gemini | gemini | GEMINI_API_KEY |
| Ollama | ollama | local or hosted base URL |
| Bedrock | bedrock | application-provided AWS SDK configuration |
Create native provider clients
Each native client implements the same provider model contract:
use runifold::ProviderModelExt;
use runifold_providers::{
anthropic::AnthropicClient,
gemini::GeminiClient,
ollama::OllamaClient,
openai::OpenAiClient,
};
let openai = OpenAiClient::from_api_key(
std::env::var("OPENAI_API_KEY")?
)?.runtime("gpt-5")?;
let anthropic = AnthropicClient::from_api_key(
std::env::var("ANTHROPIC_API_KEY")?
)?.runtime("claude-sonnet-4-5")?;
let gemini = GeminiClient::from_api_key(
std::env::var("GEMINI_API_KEY")?
)?.runtime("gemini-2.5-flash")?;
let ollama = OllamaClient::local()?.runtime("llama3.2")?;Model names are provider-controlled identifiers. Use a model available to your account and record the exact identifier in deployment configuration and test evidence.
Configure a compatible endpoint
For an application-owned gateway or a verified compatible service, declare the provider identity, endpoint, and wire protocol explicitly:
use runifold::ProviderModelExt;
use runifold_providers::{
openai::{OpenAiClient, OpenAiConfig, OpenAiWireProtocol},
};
let config = OpenAiConfig::compatible(
"private-gateway",
std::env::var("MODEL_GATEWAY_KEY")?,
"https://models.example.com/v1/",
OpenAiWireProtocol::ChatCompletions,
)?;
let runtime = OpenAiClient::new(config)
.runtime("organization/model-name")?;Do not accept arbitrary base URLs from end users. Allowlist endpoints and treat “OpenAI-compatible” as a protocol claim, not a promise of identical Tool, streaming, reasoning, usage, or error semantics.
Keep credentials at the server boundary
Load long-lived credentials through the deployment secret store. Never put provider keys in source control, browser bundles, mobile applications, or WASM. Browser and edge clients should call an application-owned gateway that authenticates the user and adds upstream credentials server-side.
Log provider identity, model identity, request correlation, capability evidence, and sanitized error classification. Do not log secrets or raw sensitive content.
Verify the exact combination
Before production, prove four increasingly strong claims:
- the selected feature and example compile;
- offline protocol and error-classification tests pass;
- a live smoke test succeeds with the real endpoint;
- the exact model-feature combination is observed in production.
Structured output, Tools, images, reasoning, and usage may vary by model even inside one provider. Use Provider testing and reliability evidence rather than assuming support.