Providers
from openprogram.runtime.agent.runtime.factory import create_runtime
rt = create_runtime() # auto-detect
rt = create_runtime(provider="anthropic") # its default model
rt = create_runtime(provider="openai-codex", model="gpt-5.5")
provider | Builds | Default model | Credential |
|---|---|---|---|
anthropic | Runtime("anthropic:<id>") | claude-sonnet-4-6 | Anthropic API key |
openai | Runtime("openai:<id>") | gpt-4.1 | OpenAI API key |
gemini | Runtime("google:<id>") | gemini-2.5-flash | Google API key |
openai-codex | OpenAICodexRuntime | gpt-5.5 | ChatGPT subscription OAuth, ~/.codex/auth.json |
gemini-cli | GeminiCLIRuntime | gemini-2.5-flash | Google account OAuth, ~/.gemini/oauth_creds.json |
| any other | Runtime("provider:model") | first enabled model | Provider's key |
API keys live in the credential store: Settings → Model services, or openprogram providers login <provider> --api-key. The Anthropic, OpenAI and Google SDKs ship as base dependencies; the OAuth providers talk raw HTTP.
Functions
| Function | Behaviour |
|---|---|
create_runtime(provider=None, model=None, **kwargs) | Returns a ready Runtime. None or "auto" runs detect_provider(). **kwargs go to the constructor. Every runtime has an authoritative provider_id. |
detect_provider() -> (name, default_model) | Order below. Raises RuntimeError with setup guidance when nothing is found. |
check_providers() -> dict | {name: {"available": bool, "method": "CLI"|"API", "model": default}} for the five dedicated providers; "default": True marks the one detection would pick |
from openprogram.models.providers.catalog.registry import detect_provider, check_providers
Detection order
- Environment:
AGENTIC_PROVIDER/AGENTIC_MODEL ~/.openprogram/config.json→last_used_model- Caller environment: inside Codex CLI, use it
- CLI binaries:
codex→openai-codex,gemini→gemini-cli - Stored API keys: anthropic → openai → google
API-key providers
rt = create_runtime(provider="anthropic", api_key="sk-ant-...", model="claude-sonnet-4-6")
rt = create_runtime(provider="openai", api_key="sk-...", model="gpt-4.1")
rt = create_runtime(provider="gemini", api_key="...", model="gemini-2.5-flash")
| Parameter | Default | Meaning |
|---|---|---|
api_key | None | str | None; a given key is sent as is. None lets each request choose from the provider's list of keys and sign-ins, switching to the next when one is limited or refused; ValueError when the provider has none. |
model | see table above | Id under the provider's namespace (anthropic, openai, google) |
max_retries | OPENPROGRAM_MAX_RETRIES, else 6 | Retry budget forwarded to the base Runtime |
provider | Wire API | Notes |
|---|---|---|
anthropic | Anthropic Messages | list_models() returns the enabled model ids |
openai | OpenAI Responses | Azure or a local OpenAI-compatible server: add a custom provider |
gemini | Google Generative Language | Env names accepted when adding a key: GEMINI_API_KEY, GOOGLE_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY |
All include streaming, the tool loop and DAG recording. Custom provider: Settings → Model services → Add custom provider (name and base URL), then Runtime(model="<provider>:<model>") or create_runtime(provider="<provider>"). A host-only base URL resolves to /v1; an explicit API path is preserved.
Subscription providers
openai-codex | gemini-cli | |
|---|---|---|
| Setup | npm install -g @openai/codexcodex login | npm install -g @google/gemini-cligemini |
| Login | OAuth; do not pick the API-key option | First run performs OAuth |
| Backend | ChatGPT Responses. Refreshed tokens are mirrored back so the Codex CLI stays in sync. | Cloud Code Assist over HTTP, no subprocess |
model | Default gpt-5.5; an openai-codex: prefix is stripped | Default gemini-2.5-flash; must match a gemini-subscription/<id> registry entry |
system | str | None, optional system prompt | str | None, optional system prompt |
profile | Auth profile, keyword-only; default active | Auth profile, keyword-only; default active |
| Wrong credential | A bare OpenAI API key raises AuthConfigError; use openai | With only a Google API key, use gemini |
Extra keyword arguments are accepted and ignored.
Every other provider
from openprogram.runtime.agent.runtime import Runtime
rt = Runtime(model="deepseek:deepseek-chat")
# or
rt = create_runtime(provider="deepseek", model="deepseek-chat")
deepseek, groq, openrouter, minimax, kimi and the rest of the catalogue go through the model registry, the path the chat dispatcher uses. With no model and none registered, ValueError: enable some in Settings → Model services or see openprogram providers available <provider>.
Custom providers
from openprogram.runtime.agent.runtime import Runtime
class MyRuntime(Runtime):
def __init__(self, api_key, model="my-model"):
super().__init__(model=model)
self.api_key = api_key
def _call(self, content, model="default", response_format=None):
texts = [b["text"] for b in content if b["type"] == "text"]
return my_api_call("\n".join(texts), model=model)
_call() takes content: list[dict] and returns str. Runtime(call=fn) does the same without a subclass.