OpenAI conversation
Type: conversation.openai
Status: alpha
Reference: https://docs.dapr.io/reference/components-reference/supported-conversation/openai/
Example
apiVersion: cra.diagrid.io/v1beta1
kind: Component
metadata:
name: <name>
spec:
type: conversation.openai
version: v1
metadata:
# API key for OpenAI.
- name: key
value: |
**********
# The type of API to use for the OpenAI service. This is required when using Azure OpenAI. (Optional)
#- name: apiType
# value: "open_ai"
# The API version to use for the Azure OpenAI service. This is required when using Azure OpenAI. (Optional)
#- name: apiVersion
# value: "2025-01-01-preview"
# A time-to-live value for a prompt cache to expire. Uses Golang durations (Optional)
#- name: cacheTTL
# value: "10m"
# Custom API endpoint URL for OpenAI API-compatible services. If not specified, the default OpenAI API endpoint will be used. (Optional)
#- name: endpoint
# value: "https://api.openai.com/v1"
# Default maximum number of tokens the model may generate per request. A request-level maxTokens value greater than zero overrides this default. When unset, no cap is sent and the provider's own default applies. (Optional)
#- name: maxTokens
# value: "2048"
# The OpenAI LLM to use. Configurable via OPENAI_MODEL environment variable. (Optional)
#- name: model
# value: "gpt-5-nano"
# Send the token cap as max_tokens instead of max_completion_tokens. Set this when endpoint points at an OpenAI-compatible service that does not recognise max_completion_tokens, otherwise the cap is ignored. (Optional)
#- name: useLegacyMaxTokensField
# value: "false"
# Send requests to OpenAI's Responses API (/v1/responses) instead of the Chat Completions API. Set this to use function tools with reasoning models that reject tools on Chat Completions. Not supported when apiType is azure. (Optional)
#- name: useResponsesAPI
# value: "false"
Authentication profiles
Available authentication profiles:
-
API Key
-
Workload identity federation (SPIFFE)
-
Azure OpenAI: Microsoft Entra ID
API Key
Authenticate using an API key
key (string)
Required - API key for OpenAI.
Example value:
**********
Workload identity federation (SPIFFE)
Authenticate to OpenAI without an API key. The Dapr runtime mints a JWT SVID for the app's SPIFFE ID, which is exchanged for a short-lived OpenAI access token. Requires mTLS and Sentry JWT issuing, with Sentry registered as an OpenAI workload identity provider. Not supported when apiType is 'azure'.
identityProviderId (string)
Required - ID of the OpenAI workload identity provider registered for Sentry.
Example value: idp_01abc
serviceAccountId (string)
Required - ID of the OpenAI service account the access token acts as.
Example value: svc_acct_01abc
audience (string)
Audience of the JWT SVID. Must match the audience of the workload identity provider.
Default value: https://api.openai.com/v1
Example value: https://api.openai.com/v1
Azure OpenAI: Microsoft Entra ID
Authenticate to Azure OpenAI with Microsoft Entra ID when apiType is 'azure' and key is not set. Supports the standard Azure authentication methods, including SPIFFE workload identity, where the Dapr runtime's JWT SVID is used as a federated credential.
azureAuthMethods (string)
Comma-separated list of the Azure authentication methods to try, in order. Use 'spiffe' to only use the Dapr SPIFFE identity.
Example value: spiffe
azureClientId (string)
Client ID of the Microsoft Entra ID application or managed identity.
Example value: 00000000-0000-0000-0000-000000000000
azureTenantId (string)
ID of the Microsoft Entra ID tenant.
Example value: 00000000-0000-0000-0000-000000000000
Metadata
apiType (string)
The type of API to use for the OpenAI service. This is required when using Azure OpenAI.
Default value: open_ai
Example value: azure
Allowed values:
-
open_ai
-
azure
apiVersion (string)
The API version to use for the Azure OpenAI service. This is required when using Azure OpenAI.
Example value: 2025-01-01-preview
cacheTTL (string)
A time-to-live value for a prompt cache to expire. Uses Golang durations
Example value: 10m
endpoint (string)
Custom API endpoint URL for OpenAI API-compatible services. If not specified, the default OpenAI API endpoint will be used.
Example value: https://api.openai.com/v1
maxTokens (number)
Default maximum number of tokens the model may generate per request. A request-level maxTokens value greater than zero overrides this default. When unset, no cap is sent and the provider's own default applies.
Example value: 2048
model (string)
The OpenAI LLM to use. Configurable via OPENAI_MODEL environment variable.
Default value: gpt-5-nano
Example value: gpt-5-nano
useLegacyMaxTokensField (bool)
Send the token cap as max_tokens instead of max_completion_tokens. Set this when endpoint points at an OpenAI-compatible service that does not recognise max_completion_tokens, otherwise the cap is ignored.
Default value: false
Example value: true
useResponsesAPI (bool)
Send requests to OpenAI's Responses API (/v1/responses) instead of the Chat Completions API. Set this to use function tools with reasoning models that reject tools on Chat Completions. Not supported when apiType is azure.
Default value: false
Example value: true