OpenAI

Detailed information on the OpenAI conversation component

Component format

A Dapr conversation.yaml component file has the following structure:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: openai
spec:
  type: conversation.openai
  metadata:
  - name: key
    value: mykey
  - name: model
    value: gpt-4-turbo
  - name: endpoint
    value: 'https://api.openai.com/v1'
  - name: responseCacheTTL
    value: 10m
  # - name: apiType # Optional
  #   value: 'azure'
  # - name: apiVersion # Optional
  #   value: '2025-01-01-preview'

Spec metadata fields

FieldRequiredDetailsExample
keyYAPI key for OpenAI.mykey
modelNThe OpenAI LLM to use. Defaults to gpt-5-nano, or to the OPENAI_MODEL environment variable when it is set.gpt-4-turbo
maxTokensNDefault maximum number of tokens the model may generate per request. A request-level maxTokens value overrides this default. When unset, no cap is sent and the provider’s own default applies.2048
useLegacyMaxTokensFieldNSend the token cap as max_tokens instead of max_completion_tokens. Set this when endpoint points at an OpenAI-compatible service that doesn’t recognize max_completion_tokens, otherwise the cap is ignored. Defaults to false.true
endpointNCustom API endpoint URL for OpenAI API-compatible services. If not specified, the default OpenAI API endpoint is used. Required when apiType is set to azure.https://api.openai.com/v1, https://example.openai.azure.com/
responseCacheTTLNTime-to-live for the in-memory response cache. When set, identical requests are served from cache until they expire.10m
apiTypeNSpecifies the API provider type. Required when using a provider that does not follow the default OpenAI API endpoint conventions.azure
apiVersionNThe API version to use. Required when the apiType is set to azure.2025-04-01-preview
useResponsesAPINSend requests to the OpenAI 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. Requests are sent with store: false, so OpenAI keeps no conversation state. Not supported when apiType is set to azure: the component fails to initialize. Defaults to false.true

Azure OpenAI Configuration

To configure the OpenAI component to connect to Azure OpenAI, you need to set the following metadata fields which are required for Azure’s API format.

Required fields for Azure OpenAI

When connecting to Azure OpenAI, the following fields are required:

  • apiType: Must be set to azure to enable Azure OpenAI compatibility
  • endpoint: Your Azure OpenAI resource endpoint URL (e.g., https://your-resource.openai.azure.com/)
  • apiVersion: The API version for your Azure OpenAI deployment (e.g., 2025-01-01-preview)
  • key: Your Azure OpenAI API key

Get your configuration values from: https://ai.azure.com/

Azure OpenAI component example

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: azure-openai
spec:
  type: conversation.openai
  metadata:
  - name: key
    value: "your-azure-openai-api-key"
  - name: model
    value: "gpt-4.1-nano"  # Default: gpt-4.1-nano
  - name: endpoint
    value: "https://your-resource.openai.azure.com/"
  - name: apiType
    value: "azure"
  - name: apiVersion
    value: "2025-01-01-preview"
Last modified October 22, 2026: Upmerge v1.18 into v1.19 (9805cc1cf)