feat(llm): support OpenAI Responses API via per-provider api_type

This commit is contained in:
loveuer
2026-08-13 11:46:23 +08:00
parent c8d8329dbb
commit 425f6ee5ee
9 changed files with 979 additions and 4 deletions
+22 -1
View File
@@ -8,6 +8,7 @@ model/provider switching, and local tools.
- TUI-first chat experience with a light theme by default.
- OpenAI-compatible `/v1/chat/completions` provider support.
- OpenAI Responses API (`/v1/responses`) provider support.
- Multiple providers from `~/.agentu/config.yaml`.
- Session-only provider, model, and thinking-level switching.
- Read-only project tools enabled by default.
@@ -48,6 +49,7 @@ Use `--config <path>` to load another file.
```yaml
providers:
loveuer:
api_type: chat
base_url: https://ai.loveuer.com
api_key: ${AGENTU_API_KEY}
models:
@@ -64,6 +66,19 @@ Provider names are the keys under `providers`. At startup, agentu selects the
first provider by name. Use `/model provider <name>` to switch providers for the
current session.
`api_type` selects which API protocol the provider speaks:
```text
chat OpenAI-compatible /v1/chat/completions (default)
responses OpenAI Responses API /v1/responses
```
The Responses API client converts the conversation history to Responses input
items (`user`/`assistant`/`system` messages, `function_call`, and
`function_call_output`), streams `response.output_text.delta` events, and
supports function calling through `response.output_item.added`,
`response.function_call_arguments.delta`, and `response.output_item.done`.
`models` is required. `/model model <name>` is restricted to that list. Each
entry is an object with:
@@ -83,7 +98,10 @@ none, middle, high, xhigh, max
```
When configured or changed with `/model thinking ...`, the value is sent as a
top-level OpenAI-compatible request field named `thinking`.
top-level request field named `thinking`. For OpenAI reasoning models on the
Responses API, set `thinking_param: reasoning` so the level is sent as the
official `reasoning: {"effort": ...}` field; agentu maps its `middle` level to
the official `medium` value and passes `none`, `high`, `xhigh`, `max` through.
## CLI Flags
@@ -174,5 +192,8 @@ Local config and build outputs are intentionally ignored by git.
- Provider/model/thinking changes are session-only; agentu does not write them
back to `~/.agentu/config.yaml`.
- `api_type` is per provider and cannot be changed at runtime; use
`/model provider <name>` to switch to a provider configured with a different
API type.
- The config schema is intentionally strict during MVP development. Deprecated
fields such as `provider` or `active_provider` are rejected.