Configuration for the OpenAI model provider.
The openai sub-block configures the OpenAI cloud provider. It also works with any
OpenAI-compatible endpoint, such as Azure OpenAI or a local proxy, by setting config.base_url.
| Field | Type | Required | runtime() | Description |
|---|---|---|---|---|
models | list | no | no | Allowlist of models for this provider. Each entry is a plain string or a config object with name and params. When omitted, no allowlist is enforced. |
config | block | no | Connection configuration. | |
config.api_key | string | no | yes | OpenAI API key. Wrap in secret(runtime(...)) to keep it out of build artifacts. |
config.base_url | string | no | yes | API base URL. Override to point at a compatible endpoint such as Azure OpenAI or a local proxy. |
params | block | no | Provider-level inference parameter defaults. Applied to every request unless overridden at the model level. |
The config block is optional. When omitted, the OpenAI SDK reads credentials from the
OPENAI_API_KEY environment variable using its standard resolution logic.
The params block sets inference parameter defaults for all models under this provider. All fields
are optional and support runtime().
| Field | Type | runtime() | Description |
|---|---|---|---|
max_tokens | integer | yes | Maximum number of tokens to generate. |
temperature | float | yes | Sampling temperature. |
top_p | float | yes | Nucleus sampling probability. |
top_k | integer | yes | Top-K sampling limit. |
stop_sequences | list of strings | yes | Sequences that stop generation. |
frequency_penalty | float | yes | Penalty for token frequency. |
presence_penalty | float | yes | Penalty for token presence. |
seed | integer | yes | Seed for deterministic sampling. |
provider_params | object | yes | Provider-specific parameters passed directly to the API. Use this for options not covered by the typed fields above. |
providers {
openai {
models = [
"gpt-4o-mini",
{
name = "gpt-4o"
params {
max_tokens = 8192
temperature = 0.3
}
}
]
config {
api_key = secret(runtime("OPENAI_API_KEY"))
base_url = runtime("OPENAI_BASE_URL", "https://api.openai.com/v1")
}
params {
max_tokens = 2048
temperature = 0.5
frequency_penalty = 0.1
}
}
}In this example, requests to gpt-4o-mini use the provider-level defaults. Requests to gpt-4o
use its own model-level params for max_tokens and temperature, while still inheriting
frequency_penalty from the provider-level defaults.
Always wrap API keys in secret(runtime(...)). This prevents the key from appearing in build
artifacts and the output of agentc inspect.
© 2026 pogue.dev. All rights reserved.
CC BY 4.0Search the agentc documentation