openai
Classes
OpenAIClient
OpenAIClient(client: OWUIClientBase)
Bases: ResourceBase
Client for the OpenAI-compatible endpoints.
This resource handles configuration of OpenAI providers, as well as proxying requests for chat completions, embeddings, and speech generation to the configured providers.
- Code Reference client Classes OpenWebUI Attributes openai
Source code in src/owui_client/client_base.py
Functions
get_config
Get the current OpenAI API configuration.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Configuration object containing |
Source code in src/owui_client/routers/openai.py
update_config
update_config(form_data: OpenAIConfigForm) -> dict
Update the OpenAI API configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
form_data
|
`OpenAIConfigForm`
|
The new configuration. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The updated configuration object. |
Source code in src/owui_client/routers/openai.py
get_models
Get available OpenAI models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url_idx
|
Optional[int]
|
The index of the specific provider to fetch models from. If None, fetches and merges models from all enabled providers. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing a |
Source code in src/owui_client/routers/openai.py
verify_connection
verify_connection(
form_data: ConnectionVerificationForm,
) -> dict
Verify connectivity to a specific OpenAI-compatible provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
form_data
|
`ConnectionVerificationForm`
|
The connection details to verify. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The response from the provider (typically the models list) if successful. |
Source code in src/owui_client/routers/openai.py
speech
Generate speech from text (TTS).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict
|
OpenAI-compatible speech payload (e.g. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bytes |
bytes
|
The audio file content (MP3). |
Source code in src/owui_client/routers/openai.py
chat_completions
Generate a chat completion.
Proxies the request to the appropriate OpenAI-compatible provider based on the model ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict
|
OpenAI-compatible chat completion payload (e.g. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The chat completion response object. |
Source code in src/owui_client/routers/openai.py
embeddings
Generate embeddings for the input text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
dict
|
OpenAI-compatible embeddings payload (e.g. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The embeddings response object. |
Source code in src/owui_client/routers/openai.py
proxy
Deprecated: Proxy arbitrary requests to the first OpenAI provider.
This endpoint is deprecated and may not work as expected with multiple providers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
HTTP method (e.g. "GET", "POST"). |
required |
path
|
str
|
The path to append to the base URL (e.g. "models"). |
required |
payload
|
Optional[dict]
|
JSON payload for the request. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The JSON response from the provider. |