azure.openai.responses
Module azure.openai.responses
Definitions
ballerinax/azure.openai.responses Ballerina library
Ballerina Azure OpenAI Responses connector
Overview
Azure OpenAI provides access to OpenAI's powerful language models including GPT-4o, GPT-4, and o-series models through Microsoft Azure's enterprise-grade infrastructure. It combines OpenAI's advanced AI capabilities with Azure's security, compliance, and regional availability features.
The ballerinax/azure.openai.responses package offers functionality to connect and interact with the Responses API of the Azure AI Foundry Models Service. The Responses API is a stateful API that provides a more powerful and flexible way to build AI applications, supporting features like multi-turn conversations, built-in tools (web search, file search, code interpreter), and background processing.
This connector exposes the create model response operation (POST /responses).
Setup guide
To use the Azure OpenAI Responses Connector, you must have access to an Azure OpenAI resource through a Microsoft Azure account. If you do not have an Azure account, you can sign up for one here.
Create an Azure OpenAI resource and obtain the API key
-
Sign in to the Azure Portal.
-
Search for "Azure OpenAI" in the top search bar and select Azure OpenAI from the results.
-
Click Create to create a new Azure OpenAI resource. Fill in the required details such as subscription, resource group, region, and resource name, then click Review + create and finally Create.
-
Once the resource is deployed, navigate to your Azure OpenAI resource.
-
In the left-hand menu, go to Resource Management -> Keys and Endpoint.
-
Copy one of the provided keys (Key 1 or Key 2) and the endpoint URL. Store them securely to use in your application.
Derive the service URL
The Responses API is served from the /openai/v1 base path, and the connector appends only the resource path (such as /responses) to the URL you supply. Append openai/v1 to the endpoint copied from the portal to form the service URL:
https://<resource-name>.openai.azure.com/openai/v1
If the resource was created as an Azure AI Foundry resource, use its host instead:
https://<resource-name>.services.ai.azure.com/openai/v1
Note: Passing the bare endpoint copied from the portal (
https://<resource-name>.openai.azure.com) sends requests to/responsesrather than/openai/v1/responses, which fails with a404.
Quickstart
To use the Azure OpenAI Responses connector in your Ballerina application, update the .bal file as follows:
Step 1: Import the module
Import the ballerinax/azure.openai.responses module. The ballerina/io module is also imported to print the response.
import ballerina/io; import ballerinax/azure.openai.responses;
Step 2: Create a new connector instance
Create a responses:Client with the API key and the service URL derived in the setup guide. The connector sends the key in the api-key header, which is the header Azure expects for API key authentication.
configurable string apiKey = ?; configurable string serviceUrl = ?; final responses:Client azureOpenAI = check new ({ auth: { api\-key: apiKey } }, serviceUrl);
Supply the values through a Config.toml file placed alongside the Ballerina.toml file:
apiKey = "<your-azure-openai-api-key>" serviceUrl = "https://<resource-name>.openai.azure.com/openai/v1"
Note: An Azure OpenAI API key must not be passed as
token. Azure accepts keys only in theapi-keyheader, so sending a key as a bearer token fails with a401.
Step 3: Invoke the connector operation
Now, you can utilize available connector operations.
Create a model response
The generated text is carried by the output array of the response. Each output item holds a list of content parts, and the assistant's text is in the parts of type output_text.
public function main() returns error? { responses:OpenAICreateResponse request = { model: "gpt-4o-mini", input: "What is the Ballerina programming language?" }; responses:InlineResponse200 response = check azureOpenAI->/responses.post(request); foreach responses:OpenAIOutputItem item in response.output { anydata content = item["content"]; if content !is anydata[] { continue; } foreach anydata part in content { if part is map<anydata> && part["type"] == "output_text" { io:println(part["text"]); } } } }
Note: The
output_textfield on the response is a convenience property that the official OpenAI SDKs compute on the client side by joining theoutput_textcontent parts. The REST API does not send it, so it is nil on responses returned by this connector — read the text fromoutputas shown above.
Step 4: Run the Ballerina application
bal run
Examples
The Azure OpenAI Responses connector provides practical examples illustrating usage in various scenarios. Explore these examples, covering the following use cases:
- Simple response - Create a model response using the Azure OpenAI Responses API.
Clients
azure.openai.responses: Client
Constructor
Gets invoked to initialize the connector.
init (ConnectionConfig config, string serviceUrl)- config ConnectionConfig - The configurations to be used when initializing the
connector
- serviceUrl string - URL of the target service
post responses
function post responses(OpenAICreateResponse payload, map<string|string[]> headers, *CreateResponseQueries queries) returns InlineResponse200|errorCreates a model response.
Parameters
- payload OpenAICreateResponse -
- queries *CreateResponseQueries - Queries to be sent with the request
Return Type
- InlineResponse200|error - The request has succeeded.
Records
azure.openai.responses: ApiKeysConfig
Provides API key configurations needed when communicating with a remote HTTP endpoint.
Fields
- api\-key string -
azure.openai.responses: AzureContentFilterBlocklistResult
A collection of true/false filtering results for configured custom blocklists.
Fields
- filtered boolean - A value indicating whether any of the detailed blocklists resulted in a filtering action.
- details? AzureContentFilterBlocklistResultDetails[] - The pairs of individual blocklist IDs and whether they resulted in a filtering action.
azure.openai.responses: AzureContentFilterBlocklistResultDetails
Fields
- filtered boolean - A value indicating whether the blocklist produced a filtering action.
- id string - The ID of the custom blocklist evaluated.
azure.openai.responses: AzureContentFilterCompletionTextSpan
A representation of a span of completion text as used by Azure OpenAI content filter results.
Fields
- completion_start_offset Signed32 - Offset of the UTF32 code point which begins the span.
- completion_end_offset Signed32 - Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans.
azure.openai.responses: AzureContentFilterCompletionTextSpanDetectionResult
Fields
- filtered boolean - Whether the content detection resulted in a content filtering action.
- detected boolean - Whether the labeled content category was detected in the content.
- details AzureContentFilterCompletionTextSpan[] - Detailed information about the detected completion text spans.
azure.openai.responses: AzureContentFilterCustomTopicResult
A collection of true/false filtering results for configured custom topics.
Fields
- filtered boolean - A value indicating whether any of the detailed topics resulted in a filtering action.
- details? AzureContentFilterCustomTopicResultDetails[] - The pairs of individual topic IDs and whether they are detected.
azure.openai.responses: AzureContentFilterCustomTopicResultDetails
Fields
- detected boolean - A value indicating whether the topic is detected.
- id string - The ID of the custom topic evaluated.
azure.openai.responses: AzureContentFilterDetectionResult
A labeled content filter result item that indicates whether the content was detected and whether the content was filtered.
Fields
- filtered boolean - Whether the content detection resulted in a content filtering action.
- detected boolean - Whether the labeled content category was detected in the content.
azure.openai.responses: AzureContentFilterForResponsesAPI
Fields
- blocked boolean - Indicate if the response is blocked.
- source_type string - The name of the source type of the message.
- content_filter_results AzureContentFilterResultsForResponsesAPI - A content filter result for a single response item produced by a generative AI system.
- content_filter_offsets AzureContentFilterResultOffsets -
- tool_call_id? string - The ID of the tool call associated with this content filter result, if applicable.
azure.openai.responses: AzureContentFilterResultOffsets
Fields
- start_offset Signed32 -
- end_offset Signed32 -
- check_offset Signed32 -
azure.openai.responses: AzureContentFilterResultsForResponsesAPI
Fields
- sexual? AzureContentFilterSeverityResult - A content filter category for language related to anatomical organs and genitals, romantic relationships, acts portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse.
- hate? AzureContentFilterSeverityResult - A content filter category that can refer to any content that attacks or uses pejorative or discriminatory language with reference to a person or identity group based on certain differentiating attributes of these groups including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, religion, immigration status, ability status, personal appearance, and body size.
- violence? AzureContentFilterSeverityResult - A content filter category for language related to physical actions intended to hurt, injure, damage, or kill someone or something; describes weapons, guns and related entities, such as manufactures, associations, legislation, and so on.
- self_harm? AzureContentFilterSeverityResult - A content filter category that describes language related to physical actions intended to purposely hurt, injure, damage one's body or kill oneself.
- profanity? AzureContentFilterDetectionResult - A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the content.
- custom_blocklists? AzureContentFilterBlocklistResult - A collection of binary filtering outcomes for configured custom blocklists.
- custom_topics? AzureContentFilterCustomTopicResult - A collection of binary filtering outcomes for configured custom topics.
- 'error? AzureContentFilterResultsForResponsesAPIError - If present, details about an error that prevented content filtering from completing its evaluation.
- jailbreak? AzureContentFilterDetectionResult - A detection result that describes user prompt injection attacks, where malicious users deliberately exploit system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content generation or violations of system-imposed restrictions.
- task_adherence? AzureContentFilterDetectionResult - A detection result that indicates if the execution flow still sticks the plan.
- protected_material_text? AzureContentFilterDetectionResult - A detection result that describes a match against text protected under copyright or other status.
- protected_material_code? AzureContentFilterResultsForResponsesAPIProtectedMaterialCode - A detection result that describes a match against licensed code or other protected source material.
- ungrounded_material? AzureContentFilterCompletionTextSpanDetectionResult -
- personally_identifiable_information? AzureContentFilterPersonallyIdentifiableInformationResult - A detection result that describes matches against Personal Identifiable Information with configurable subcategories.
- indirect_attack? AzureContentFilterDetectionResult - A detection result that describes attacks on systems powered by Generative AI models that can happen every time an application processes information that wasn’t directly authored by either the developer of the application or the user.
azure.openai.responses: AzureContentFilterResultsForResponsesAPIError
If present, details about an error that prevented content filtering from completing its evaluation.
Fields
- code Signed32 - A distinct, machine-readable code associated with the error.
- message string - A human-readable message associated with the error.
azure.openai.responses: AzureContentFilterResultsForResponsesAPIProtectedMaterialCode
A detection result that describes a match against licensed code or other protected source material.
Fields
- filtered boolean - Whether the content detection resulted in a content filtering action.
- detected boolean - Whether the labeled content category was detected in the content.
- citation? AzureContentFilterResultsForResponsesAPIProtectedMaterialCodeCitation - If available, the citation details describing the associated license and its location.
azure.openai.responses: AzureContentFilterResultsForResponsesAPIProtectedMaterialCodeCitation
If available, the citation details describing the associated license and its location.
Fields
- license? string - The name or identifier of the license associated with the detection.
- URL? string - The URL associated with the license.
azure.openai.responses: AzureContentFilterSeverityResult
A labeled content filter result item that indicates whether the content was filtered and what the qualitative severity level of the content was, as evaluated against content filter configuration for the category.
Fields
- filtered boolean - Whether the content severity resulted in a content filtering action.
- severity "safe"|"low"|"medium"|"high" - The labeled severity of the content.
azure.openai.responses: ConnectionConfig
Provides a set of configurations for controlling the behaviours when communicating with a remote HTTP endpoint.
Fields
- auth BearerTokenConfig|ApiKeysConfig - Provides Auth configurations needed when communicating with a remote HTTP endpoint.
- httpVersion HttpVersion(default http:HTTP_2_0) - The HTTP version understood by the client
- http1Settings ClientHttp1Settings(default {}) - Configurations related to HTTP/1.x protocol
- http2Settings ClientHttp2Settings(default {}) - Configurations related to HTTP/2 protocol
- timeout decimal(default 30) - The maximum time to wait (in seconds) for a response before closing the connection
- forwarded string(default "disable") - The choice of setting
forwarded/x-forwardedheader
- followRedirects? FollowRedirects - Configurations associated with Redirection
- poolConfig? PoolConfiguration - Configurations associated with request pooling
- cache CacheConfig(default {}) - HTTP caching related configurations
- compression Compression(default http:COMPRESSION_AUTO) - Specifies the way of handling compression (
accept-encoding) header
- circuitBreaker? CircuitBreakerConfig - Configurations associated with the behaviour of the Circuit Breaker
- retryConfig? RetryConfig - Configurations associated with retrying
- cookieConfig? CookieConfig - Configurations associated with cookies
- responseLimits ResponseLimitConfigs(default {}) - Configurations associated with inbound response size limits
- secureSocket? ClientSecureSocket - SSL/TLS-related options
- proxy? ProxyConfig - Proxy server related options
- socketConfig ClientSocketConfig(default {}) - Provides settings related to client socket configuration
- validation boolean(default true) - Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
- laxDataBinding boolean(default true) - Enables relaxed data binding on the client side. When enabled,
nilvalues are treated as optional, and absent fields are handled asnilabletypes. Enabled by default.
azure.openai.responses: CreateResponseQueries
Represents the Queries record for the operation: createResponse
Fields
- api\-version? AzureAIFoundryModelsApiVersion - The explicit Azure AI Foundry Models API version to use for this request.
v1if not otherwise specified.
azure.openai.responses: InlineResponse200
Fields
- metadata? OpenAIMetadata - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
- top_logprobs? int? -
- temperature decimal?(default 1) -
- top_p decimal?(default 1) -
- user? string - This field is being replaced by
safety_identifierandprompt_cache_key. Useprompt_cache_keyinstead to maintain caching optimizations. A stable identifier for your end-users. Used to boost cache hit rates by better bucketing similar requests and to help OpenAI detect and prevent abuse. Learn more.
- safety_identifier? string - A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies. The IDs should be a string that uniquely identifies each user, with a maximum length of 64 characters. We recommend hashing their username or email address, in order to avoid sending us any identifying information. Learn more.
- prompt_cache_key? string - Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the
userfield. Learn more.
- prompt_cache_retention? "in_memory"|"24h"? -
- previous_response_id? string? -
- model? string - Model ID used to generate the response, like
gpt-4ooro3. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models.
- reasoning? OpenAIReasoning - gpt-5 and o-series models only Configuration options for reasoning models.
- background? boolean? -
- max_tool_calls? int? -
- text? OpenAIResponseTextParam - Configuration options for a text response from the model. Can be plain text or structured JSON data. Learn more:
- tools? OpenAIToolsArray - An array of tools the model may call while generating a response. You
can specify which tool to use by setting the
tool_choiceparameter. We support the following categories of tools:- Built-in tools: Tools that are provided by OpenAI that extend the model's capabilities, like web search or file search. Learn more about built-in tools.
- MCP Tools: Integrations with third-party systems via custom MCP servers or predefined connectors such as Google Drive and SharePoint. Learn more about MCP Tools.
- Function calls (custom tools): Functions that are defined by you, enabling the model to call your own code with strongly typed arguments and outputs. Learn more about function calling. You can also use custom tools to call your own code.
- tool_choice? OpenAIToolChoiceOptions|OpenAIToolChoiceParam -
- prompt? OpenAIPrompt - Reference to a prompt template and its variables. Learn more.
- truncation "auto"|"disabled"?(default "disabled") -
- id string - Unique identifier for this Response.
- 'object "response" - The object type of this resource - always set to
response.
- status? "completed"|"failed"|"in_progress"|"cancelled"|"queued"|"incomplete" - The status of the response generation. One of
completed,failed,in_progress,cancelled,queued, orincomplete.
- created_at int - Unix timestamp (in seconds) of when this Response was created.
- completed_at? decimal? - Unix timestamp (in seconds) of when this Response was completed.
Only present when the status is
completed.
- 'error OpenAIResponseError? -
- incomplete_details OpenAIResponseIncompleteDetails? -
- output OpenAIOutputItem[] - An array of content items generated by the model.
- The length and order of items in the
outputarray is dependent on the model's response. - Rather than accessing the first item in the
outputarray and assuming it's anassistantmessage with the content generated by the model, you might consider using theoutput_textproperty where supported in SDKs.
- The length and order of items in the
- instructions string|OpenAIInputItem[]? -
- output_text? string? - SDK-only convenience property; it is not part of the REST payload.
The official OpenAI SDKs compute it on the client side by concatenating the
textof everyoutput_textcontent part inoutput. The service does not send this field, so it is nil on responses returned by this connector. Read the generated text from theoutputarray instead.
- usage? OpenAIResponseUsage - Represents token usage details including input tokens, output tokens, a breakdown of output tokens, and the total tokens used.
- parallel_tool_calls boolean(default true) - Whether to allow the model to run tool calls in parallel.
- conversation? OpenAIConversationReference - The conversation that this response belonged to. Input items and output items from this response were automatically added to this conversation.
- max_output_tokens? int? -
- content_filters? AzureContentFilterForResponsesAPI[] - The content filter results from RAI.
azure.openai.responses: OpenAIContextManagementParam
Fields
- 'type string - The context management entry type. Currently only 'compaction' is supported.
- compact_threshold? int? -
azure.openai.responses: OpenAIConversationParam2
The conversation that this response belongs to.
Fields
- id string - The unique ID of the conversation.
azure.openai.responses: OpenAIConversationReference
The conversation that this response belonged to. Input items and output items from this response were automatically added to this conversation.
Fields
- id string - The unique ID of the conversation that this response was associated with.
azure.openai.responses: OpenAICreateResponse
Fields
- metadata? OpenAIMetadata - Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
- top_logprobs? int? -
- temperature? decimal? -
- top_p? decimal? -
- user? string - This field is being replaced by
safety_identifierandprompt_cache_key. Useprompt_cache_keyinstead to maintain caching optimizations. A stable identifier for your end-users. Used to boost cache hit rates by better bucketing similar requests and to help OpenAI detect and prevent abuse. Learn more.
- safety_identifier? string - A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies. The IDs should be a string that uniquely identifies each user, with a maximum length of 64 characters. We recommend hashing their username or email address, in order to avoid sending us any identifying information. Learn more.
- prompt_cache_key? string - Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the
userfield. Learn more.
- prompt_cache_retention? "in_memory"|"24h"? -
- previous_response_id? string? -
- model? string - Model ID used to generate the response, like
gpt-4ooro3. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models.
- reasoning? OpenAIReasoning - gpt-5 and o-series models only Configuration options for reasoning models.
- background? boolean? -
- max_tool_calls? int? -
- text? OpenAIResponseTextParam - Configuration options for a text response from the model. Can be plain text or structured JSON data. Learn more:
- tools? OpenAIToolsArray - An array of tools the model may call while generating a response. You
can specify which tool to use by setting the
tool_choiceparameter. We support the following categories of tools:- Built-in tools: Tools that are provided by OpenAI that extend the model's capabilities, like web search or file search. Learn more about built-in tools.
- MCP Tools: Integrations with third-party systems via custom MCP servers or predefined connectors such as Google Drive and SharePoint. Learn more about MCP Tools.
- Function calls (custom tools): Functions that are defined by you, enabling the model to call your own code with strongly typed arguments and outputs. Learn more about function calling. You can also use custom tools to call your own code.
- tool_choice? OpenAIToolChoiceOptions|OpenAIToolChoiceParam -
- prompt? OpenAIPrompt - Reference to a prompt template and its variables. Learn more.
- truncation? "auto"|"disabled"? -
- input? OpenAIInputParam - Text, image, or file inputs to the model, used to generate a response. Learn more:
- include? OpenAIIncludeEnum[]? -
- parallel_tool_calls? boolean? -
- store? boolean? -
- instructions? string? -
- 'stream? boolean? -
- stream_options? OpenAIResponseStreamOptions - Options for streaming responses. Only set this when you set
stream: true.
- conversation? OpenAIConversationParam - The conversation that this response belongs to. Items from this conversation are prepended to
input_itemsfor this response request. Input items and output items from this response are automatically added to this conversation after this response completes.
- context_management? OpenAIContextManagementParam[]? - Context management configuration for this request.
- max_output_tokens? int? -
azure.openai.responses: OpenAIInputItem
An item representing part of the context for the response to be generated by the model. Can contain text, images, and audio inputs, as well as previous assistant responses and tool call outputs.
Fields
- 'type OpenAIInputItemType -
azure.openai.responses: OpenAIMetadata
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
azure.openai.responses: OpenAIOutputItem
Fields
- 'type OpenAIOutputItemType -
azure.openai.responses: OpenAIPrompt
Reference to a prompt template and its variables. Learn more.
Fields
- id string - The unique identifier of the prompt template to use.
- version? string? -
- variables? OpenAIResponsePromptVariables - Optional map of values to substitute in for variables in your prompt. The substitution values can either be strings, or other Response input types like images or files.
azure.openai.responses: OpenAIReasoning
gpt-5 and o-series models only Configuration options for reasoning models.
Fields
- effort? OpenAIReasoningEffort? - Constrains effort on reasoning for
reasoning models.
Currently supported values are
none,minimal,low,medium,high, andxhigh. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.gpt-5.1defaults tonone, which does not perform reasoning. The supported reasoning values forgpt-5.1arenone,low,medium, andhigh. Tool calls are supported for all reasoning values in gpt-5.1.- All models before
gpt-5.1default tomediumreasoning effort, and do not supportnone. - The
gpt-5-promodel defaults to (and only supports)highreasoning effort. xhighis supported for all models aftergpt-5.1-codex-max.
- summary? "auto"|"concise"|"detailed"? -
- generate_summary? "auto"|"concise"|"detailed"? -
azure.openai.responses: OpenAIResponseError
An error object returned when the model fails to generate a Response.
Fields
- code OpenAIResponseErrorCode - The error code for the response.
- message string - A human-readable description of the error.
azure.openai.responses: OpenAIResponseIncompleteDetails
Fields
- reason? "max_output_tokens"|"content_filter" -
azure.openai.responses: OpenAIResponsePromptVariables
Optional map of values to substitute in for variables in your prompt. The substitution values can either be strings, or other Response input types like images or files.
azure.openai.responses: OpenAIResponseStreamOptions
Options for streaming responses. Only set this when you set stream: true.
Fields
- include_obfuscation? boolean - When true, stream obfuscation will be enabled. Stream obfuscation adds
random characters to an
obfuscationfield on streaming delta events to normalize payload sizes as a mitigation to certain side-channel attacks. These obfuscation fields are included by default, but add a small amount of overhead to the data stream. You can setinclude_obfuscationto false to optimize for bandwidth if you trust the network links between your application and the OpenAI API.
azure.openai.responses: OpenAIResponseTextParam
Configuration options for a text response from the model. Can be plain text or structured JSON data. Learn more:
Fields
- format? OpenAITextResponseFormatConfiguration - An object specifying the format that the model must output.
Configuring
{ "type": "json_schema" }enables Structured Outputs, which ensures the model will match your supplied JSON schema. Learn more in the Structured Outputs guide. The default format is{ "type": "text" }with no additional options. Not recommended for gpt-4o and newer models:* Setting to{ "type": "json_object" }enables the older JSON mode, which ensures the message the model generates is valid JSON. Usingjson_schemais preferred for models that support it.
- verbosity? OpenAIVerbosity? - Constrains the verbosity of the model's response. Lower values will result in
more concise responses, while higher values will result in more verbose responses.
Currently supported values are
low,medium, andhigh.
azure.openai.responses: OpenAIResponseUsage
Represents token usage details including input tokens, output tokens, a breakdown of output tokens, and the total tokens used.
Fields
- input_tokens int - The number of input tokens.
- input_tokens_details OpenAIResponseUsageInputTokensDetails - A detailed breakdown of the input tokens.
- output_tokens int - The number of output tokens.
- output_tokens_details OpenAIResponseUsageOutputTokensDetails - A detailed breakdown of the output tokens.
- total_tokens int - The total number of tokens used.
azure.openai.responses: OpenAIResponseUsageInputTokensDetails
Fields
- cached_tokens int -
azure.openai.responses: OpenAIResponseUsageOutputTokensDetails
Fields
- reasoning_tokens int -
azure.openai.responses: OpenAITextResponseFormatConfiguration
An object specifying the format that the model must output.
Configuring { "type": "json_schema" } enables Structured Outputs,
which ensures the model will match your supplied JSON schema. Learn more in the
Structured Outputs guide.
The default format is { "type": "text" } with no additional options.
Not recommended for gpt-4o and newer models:*
Setting to { "type": "json_object" } enables the older JSON mode, which
ensures the message the model generates is valid JSON. Using json_schema
is preferred for models that support it.
Fields
azure.openai.responses: OpenAITool
A tool that can be used to generate a response.
Fields
- 'type OpenAIToolType -
azure.openai.responses: OpenAIToolChoiceParam
How the model should select which tool (or tools) to use when generating
a response. See the tools parameter to see how to specify which tools
the model can call.
Fields
- 'type OpenAIToolChoiceParamType -
Union types
azure.openai.responses: OpenAIIncludeEnum
OpenAIIncludeEnum
Specify additional output data to include in the model response. Currently supported values are:
web_search_call.results: Include the search results of the web search tool call.web_search_call.action.sources: Include the sources of the web search tool call.code_interpreter_call.outputs: Includes the outputs of python code execution in code interpreter tool call items.computer_call_output.output.image_url: Include image urls from the computer call output.file_search_call.results: Include the search results of the file search tool call.message.input_image.image_url: Include image urls from the input message.message.output_text.logprobs: Include logprobs with assistant messages.reasoning.encrypted_content: Includes an encrypted version of reasoning tokens in reasoning item outputs. This enables reasoning items to be used in multi-turn conversations when using the Responses API statelessly (like when thestoreparameter is set tofalse, or when an organization is enrolled in the zero data retention program).
azure.openai.responses: AzureAIFoundryModelsApiVersion
AzureAIFoundryModelsApiVersion
azure.openai.responses: OpenAIInputItemType
OpenAIInputItemType
azure.openai.responses: OpenAIToolChoiceOptions
OpenAIToolChoiceOptions
Controls which (if any) tool is called by the model.
none means the model will not call any tool and instead generates a message.
auto means the model can pick between generating a message or calling one or
more tools.
required means the model must call one or more tools.
azure.openai.responses: OpenAITextResponseFormatConfigurationType
OpenAITextResponseFormatConfigurationType
azure.openai.responses: OpenAIToolType
OpenAIToolType
azure.openai.responses: OpenAIInputParam
OpenAIInputParam
Text, image, or file inputs to the model, used to generate a response. Learn more:
azure.openai.responses: OpenAIReasoningEffort
OpenAIReasoningEffort
Constrains effort on reasoning for
reasoning models.
Currently supported values are none, minimal, low, medium, high, and xhigh. Reducing
reasoning effort can result in faster responses and fewer tokens used
on reasoning in a response.
gpt-5.1defaults tonone, which does not perform reasoning. The supported reasoning values forgpt-5.1arenone,low,medium, andhigh. Tool calls are supported for all reasoning values in gpt-5.1.- All models before
gpt-5.1default tomediumreasoning effort, and do not supportnone. - The
gpt-5-promodel defaults to (and only supports)highreasoning effort. xhighis supported for all models aftergpt-5.1-codex-max.
azure.openai.responses: OpenAIVerbosity
OpenAIVerbosity
Constrains the verbosity of the model's response. Lower values will result in
more concise responses, while higher values will result in more verbose responses.
Currently supported values are low, medium, and high.
azure.openai.responses: OpenAIConversationParam
OpenAIConversationParam
The conversation that this response belongs to. Items from this conversation are prepended to input_items for this response request.
Input items and output items from this response are automatically added to this conversation after this response completes.
azure.openai.responses: OpenAIOutputItemType
OpenAIOutputItemType
azure.openai.responses: OpenAIResponseErrorCode
OpenAIResponseErrorCode
The error code for the response.
azure.openai.responses: OpenAIToolChoiceParamType
OpenAIToolChoiceParamType
Array types
azure.openai.responses: OpenAIToolsArray
OpenAIToolsArray
An array of tools the model may call while generating a response. You
can specify which tool to use by setting the tool_choice parameter.
We support the following categories of tools:
- Built-in tools: Tools that are provided by OpenAI that extend the model's capabilities, like web search or file search. Learn more about built-in tools.
- MCP Tools: Integrations with third-party systems via custom MCP servers or predefined connectors such as Google Drive and SharePoint. Learn more about MCP Tools.
- Function calls (custom tools): Functions that are defined by you, enabling the model to call your own code with strongly typed arguments and outputs. Learn more about function calling. You can also use custom tools to call your own code.
Simple name reference types
azure.openai.responses: AzureContentFilterPersonallyIdentifiableInformationResult
AzureContentFilterPersonallyIdentifiableInformationResult
A content filter detection result for Personally Identifiable Information that includes harm extensions.
Import
import ballerinax/azure.openai.responses;Other versions
1.0.0
Metadata
Released date: about 13 hours ago
Version: 1.0.0
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: 2201.12.0
GraalVM compatible: Yes
Pull count
Total: 8
Current verison: 8
Weekly downloads
Keywords
AI
Azure
Azure OpenAI
Responses
Vendor/Microsoft
Contributors