Agently documentation for building AI applications with stable outputs, observable actions, and durable workflows.
Languages: English · 中文
OpenAICompatible is one of the three protocol-level model request plugins (see Models Overview). It handles any endpoint that speaks the OpenAI Chat Completions API — which today covers most commercial providers and most local model servers.
from agently import Agently
Agently.set_settings("OpenAICompatible", {
"base_url": "https://api.openai.com/v1",
"api_key": "${ENV.OPENAI_API_KEY}",
"model": "${ENV.OPENAI_MODEL}",
})
| Key | Meaning |
|---|---|
base_url |
the API root, e.g. https://api.openai.com/v1 |
api_key |
bearer token; omit for local servers that don’t require auth |
model |
provider-specific model name |
model_type |
"chat" (default) or "completion" for legacy completion endpoints |
request_options |
extra dict forwarded to the underlying HTTP client (timeouts, headers) |
The full set lives in agently/builtins/plugins/ModelRequester/OpenAICompatible.py.
Some providers (and OpenAI itself for newer models) speak the Responses API rather than Chat Completions. Agently has a sibling plugin:
Agently.set_settings("OpenAIResponsesCompatible", {
"base_url": "https://api.openai.com/v1",
"api_key": "${ENV.OPENAI_API_KEY}",
"model": "${ENV.OPENAI_RESPONSES_MODEL}",
})
OpenAIResponsesCompatible is a sibling of OpenAICompatible; pick whichever matches the protocol your endpoint exposes. Both plugins directly implement ModelRequester; neither plugin inherits from the other.
A provider qualifies as OpenAI-compatible when its endpoint:
messages: [{"role": ..., "content": ...}, ...].model, temperature, max_tokens, tools, etc.Providers that fit:
https://api.deepseek.com/v1)https://dashscope.aliyuncs.com/compatible-mode/v1)https://api.moonshot.cn/v1)https://open.bigmodel.cn/api/paas/v4/)http://127.0.0.1:11434/v1For per-provider recipes, see Providers.
Agent-level settings override the global preset:
agent = Agently.create_agent()
agent.set_settings("OpenAICompatible", {"model": "${ENV.OPENAI_MODEL_FAST}"})
You can also set request-level overrides via the request chain — see Settings.
OpenAICompatible handles both streaming responses (used by get_generator(...) / get_async_generator(...)) and tool calling (used by the action runtime). You don’t need to enable these per-provider — they’re on as the protocol allows.
If a particular provider doesn’t fully implement OpenAI semantics for one of these (e.g., a quirky streaming format), the underlying plugin tries to be tolerant; report concrete cases via issues.