mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-13 23:07:47 +00:00
feat(openai): Add verbosity parameter support for GPT-5 family models (#16660)
OpenAI's GPT-5 model family supports a verbosity parameter to control the length and detail of responses. This parameter accepts three values: 'low', 'medium', or 'high'. Changes: - Added verbosity parameter to completion() and acompletion() signatures - Added verbosity to DEFAULT_CHAT_COMPLETION_PARAM_VALUES in constants.py - Added verbosity to get_optional_params() in utils.py - Added verbosity to GPT-5 supported params list - Updated OpenAI docs with verbosity usage examples - Added comprehensive test for verbosity parameter Supported models: gpt-5, gpt-5.1, gpt-5-mini, gpt-5-nano, gpt-5-codex, gpt-5-pro
This commit is contained in:
@@ -486,6 +486,53 @@ curl -X POST 'http://0.0.0.0:4000/chat/completions' \
|
||||
|
||||
See [OpenAI Reasoning documentation](https://platform.openai.com/docs/guides/reasoning) for more details on organization verification requirements.
|
||||
|
||||
### Verbosity Control for GPT-5 Models
|
||||
|
||||
The `verbosity` parameter controls the length and detail of responses from GPT-5 family models. It accepts three values: `"low"`, `"medium"`, or `"high"`.
|
||||
|
||||
**Supported models:** All GPT-5 family models (`gpt-5`, `gpt-5.1`, `gpt-5-mini`, `gpt-5-nano`, `gpt-5-codex`, `gpt-5-pro`)
|
||||
|
||||
**Use cases:**
|
||||
- **`"low"`**: Best for concise answers or simple code generation (e.g., SQL queries)
|
||||
- **`"medium"`**: Default - balanced output length
|
||||
- **`"high"`**: Use when you need thorough explanations or extensive code refactoring
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="sdk" label="SDK">
|
||||
```python
|
||||
import litellm
|
||||
|
||||
# Low verbosity - concise responses
|
||||
response = litellm.completion(
|
||||
model="gpt-5.1",
|
||||
messages=[{"role": "user", "content": "Write a function to reverse a string"}],
|
||||
verbosity="low"
|
||||
)
|
||||
|
||||
# High verbosity - detailed responses
|
||||
response = litellm.completion(
|
||||
model="gpt-5.1",
|
||||
messages=[{"role": "user", "content": "Explain how neural networks work"}],
|
||||
verbosity="high"
|
||||
)
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="proxy" label="PROXY">
|
||||
```bash
|
||||
curl -X POST 'http://0.0.0.0:4000/chat/completions' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Authorization: Bearer sk-1234' \
|
||||
-d '{
|
||||
"model": "gpt-5.1",
|
||||
"messages": [{"role": "user", "content": "Write a function to reverse a string"}],
|
||||
"verbosity": "low"
|
||||
}'
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
||||
## OpenAI Chat Completion to Responses API Bridge
|
||||
|
||||
Call any Responses API model from OpenAI's `/chat/completions` endpoint.
|
||||
|
||||
Reference in New Issue
Block a user