Provider and Model
A provider is the model-protocol adapter, not the agent itself. CodeN currently implements OpenAI and Anthropic providers. You choose the model ID; CodeN maintains no capability allowlist and does not silently pretend success when a service rejects a parameter.
Configure Your First Provider
Section titled “Configure Your First Provider”CodeN supports exactly two providers: openai (default) and anthropic. The provider determines the API endpoint, authentication, and thinking-parameter mapping; the default model is gpt-5-mini.
OpenAI (default provider)
Section titled “OpenAI (default provider)”export CODEN_OPENAI_API_KEY=sk-...coden "say hello"Custom compatible endpoint (proxy or compatible service):
export CODEN_OPENAI_API_KEY=sk-...export CODEN_OPENAI_BASE_URL=https://api.example.com/v1coden --model your-model-id "say hello"Anthropic
Section titled “Anthropic”export CODEN_ANTHROPIC_API_KEY=sk-ant-...coden --provider anthropic --model claude-sonnet-4-20250514 "say hello"Switching providers requires an explicit --provider anthropic. The provider accepts only openai or anthropic; any other value fails argument parsing.
Credential sources and precedence
Section titled “Credential sources and precedence”CodeN reads process environment variables when constructing the provider. Sources, highest first:
- Environment variables already exported in the shell before starting CodeN.
- The config
envfield: injected into the process environment at config load time, but it does not overwrite an already-exported shell variable of the same name. - With no key set, startup fails with exit code 2 and an error shaped like
CODEN_OPENAI_API_KEY is required.
Config env example (user scope, ~/.config/coden/config.json):
{ "env": { "CODEN_OPENAI_API_KEY": "sk-..." }}A project-level <workspace>/.coden/config.json accepts the same env field; when both scopes are merged, project-level keys override user-level keys one by one.
Secret placement boundaries
Section titled “Secret placement boundaries”- Never put a key in a directory that gets committed, shared, or distributed. Supported locations are
~/.config/coden/,.coden/(excluded by.gitignore), and the configenvfield. - CodeN does not read
.envfiles automatically;set dotenv-loadinjustaffects onlyjustsubprocesses during development. - Session JSONL and trace files may contain model reasoning and user input; do not share them without review.
Verify a minimal configuration
Section titled “Verify a minimal configuration”coden -p "Reply with exactly: coden-ok"Print mode emits plain text and exits after a single turn, which makes it a good authentication and endpoint check. The expected output contains coden-ok.
Related references
Section titled “Related references”- Precedence
- User and Project Scopes
- Environment Variables
- OpenAI Configuration
- Anthropic Configuration
- Data Security
OpenAI Configuration
Section titled “OpenAI Configuration”Minimal configuration
Section titled “Minimal configuration”export CODEN_OPENAI_API_KEY=sk-...codenopenai is the default provider with model gpt-5-mini. Overrides:
export CODEN_MODEL=gpt-5-minicoden --model gpt-5-mini "your task"Compatible endpoints
Section titled “Compatible endpoints”export CODEN_OPENAI_API_KEY=sk-...export CODEN_OPENAI_BASE_URL=https://api.example.com/v1coden --model your-model-id "your task"CODEN_OPENAI_BASE_URL is consumed directly by the OpenAI SDK; any SDK-compatible endpoint works, but CodeN maintains no model capability allowlist and sends parameters as-is.
Request shape
Section titled “Request shape”- Uses the streaming
chat.completionsAPI withstream_options.include_usagefor usage. - Tools are passed as OpenAI function calling (
type: "function", name/description/JSON Schema). max_completion_tokensof every request equalsreservedOutputTokens(default 8192).- The SDK’s internal
maxRetriesis 0: retries are owned by the agent loop (up to 3 exponential backoffs; see Agent Loop).
Thinking parameter
Section titled “Thinking parameter”--thinking levels map to reasoning_effort; off maps to minimal (shown as off→minimal), and minimal/low/medium/high map to the same-named values. default sends nothing. See Language and Thinking Levels.
Config example
Section titled “Config example”{ "provider": "openai", "model": "gpt-5-mini", "approvalModel": "gpt-5-mini"}Failure modes
Section titled “Failure modes”- Missing
CODEN_OPENAI_API_KEY: startup fails (exit code 2). - Invalid model/endpoint: provider errors surface with the
providercategory; failure follows once retry slots are exhausted.
Related references
Section titled “Related references”Anthropic Configuration
Section titled “Anthropic Configuration”Minimal configuration
Section titled “Minimal configuration”export CODEN_ANTHROPIC_API_KEY=sk-ant-...coden --provider anthropic --model claude-sonnet-4-20250514 "your task"Anthropic is not the default provider: pass --provider anthropic explicitly (or set provider: "anthropic"). approvalModel uses the same Anthropic credentials.
Config example
Section titled “Config example”{ "provider": "anthropic", "model": "claude-sonnet-4-20250514", "approvalStrictness": "hard"}Request shape
Section titled “Request shape”- Uses the streaming
messages.streamAPI;max_tokensequalsreservedOutputTokens. - Tools are passed as Anthropic tools (
name/description/input_schema). - The SDK’s internal
maxRetriesis 0: retries are owned by the agent loop. - Thinking blocks (
thinking/redacted_thinkingand signatures) persist asproviderStateand are replayed unchanged after tool calls and resume; mismatched state is ignored when switching providers.
Thinking budgets
Section titled “Thinking budgets”| Level | Behavior |
|---|---|
default |
no thinking parameter sent |
off |
sends { "type": "disabled" } |
minimal |
1024-token budget |
low / medium / high |
25% / 50% / 75% of reservedOutputTokens, clamped to [1024, reservedOutputTokens − 1] |
| any enabled level | requires reservedOutputTokens > 1024, otherwise a configuration error (exit code 2) |
The budget counts inside reservedOutputTokens: a higher level leaves fewer tokens for final text and tool calls in the same response.
Failure modes
Section titled “Failure modes”- Missing
CODEN_ANTHROPIC_API_KEY: startup fails (exit code 2). reservedOutputTokens <= 1024with an enabled thinking level:thinking: ...configuration error.- When a model rejects the requested thinking parameters, the error surfaces as-is with no silent downgrade.