OpenAIResponsesLanguageModel
Namespace: Vercel.AI.OpenAI
public sealed class OpenAIResponsesLanguageModel : ILanguageModelOpenAI Responses API language model.
Inheritance: object
Implements: ILanguageModel
Constructors
Section titled “Constructors”OpenAIResponsesLanguageModel(AzureOpenAIProvider, string)
Section titled “OpenAIResponsesLanguageModel(AzureOpenAIProvider, string)”public OpenAIResponsesLanguageModel(AzureOpenAIProvider provider, string modelId)Creates an Azure OpenAI Responses model. Message and request options are read from the
azure provider options first and fall back to openai when azure is absent.
Parameters
| Name | Type | Description |
|---|---|---|
provider |
AzureOpenAIProvider | |
modelId |
string |
OpenAIResponsesLanguageModel(AzureOpenAIProvider, string, AzureOpenAILanguageModelSettings?)
Section titled “OpenAIResponsesLanguageModel(AzureOpenAIProvider, string, AzureOpenAILanguageModelSettings?)”public OpenAIResponsesLanguageModel(AzureOpenAIProvider provider, string deploymentId, AzureOpenAILanguageModelSettings? settings)Creates an Azure OpenAI Responses model for a deployment. ModelId reports <code class=“paramref”>settings</code>.ModelId when set and drives capability detection. Requests always use <code class=“paramref”>deploymentId</code>.
Parameters
| Name | Type | Description |
|---|---|---|
provider |
AzureOpenAIProvider | |
deploymentId |
string | |
settings |
AzureOpenAILanguageModelSettings |
OpenAIResponsesLanguageModel(OpenAIProvider, string)
Section titled “OpenAIResponsesLanguageModel(OpenAIProvider, string)”public OpenAIResponsesLanguageModel(OpenAIProvider provider, string modelId)Creates a Responses model.
Parameters
| Name | Type | Description |
|---|---|---|
provider |
OpenAIProvider | |
modelId |
string |
Properties
Section titled “Properties”ModelId
Section titled “ModelId”public string ModelId { get; }Model id.
Value: string
Provider
Section titled “Provider”public string Provider { get; }Provider id, such as openai.
Value: string
SpecificationVersion
Section titled “SpecificationVersion”public string SpecificationVersion { get; }Always V4.
Value: string
SupportsWebSearchSourcesInclude
Section titled “SupportsWebSearchSourcesInclude”public bool SupportsWebSearchSourcesInclude { get; init; }Whether a request with a web_search or web_search_preview tool adds
web_search_call.action.sources to include. The default is true. The
includeWebSearchSources provider option set to false also turns it off.
Value: bool
Methods
Section titled “Methods”DoGenerateAsync(LanguageModelCallOptions, CancellationToken)
Section titled “DoGenerateAsync(LanguageModelCallOptions, CancellationToken)”public Task<LanguageModelGenerateResult> DoGenerateAsync(LanguageModelCallOptions options, CancellationToken cancellationToken)Generates a complete result.
Parameters
| Name | Type | Description |
|---|---|---|
options |
LanguageModelCallOptions | |
cancellationToken |
CancellationToken |
Returns: Task<LanguageModelGenerateResult>
DoStreamAsync(LanguageModelCallOptions, CancellationToken)
Section titled “DoStreamAsync(LanguageModelCallOptions, CancellationToken)”public Task<LanguageModelStreamResult> DoStreamAsync(LanguageModelCallOptions options, CancellationToken cancellationToken)Streams partial results. The result carries the stream with the request and response info.
Parameters
| Name | Type | Description |
|---|---|---|
options |
LanguageModelCallOptions | |
cancellationToken |
CancellationToken |
Returns: Task<LanguageModelStreamResult>
Prepare(string, LanguageModelCallOptions, bool)
Section titled “Prepare(string, LanguageModelCallOptions, bool)”public static OpenAIResponsesPreparedRequest Prepare(string modelId, LanguageModelCallOptions options, bool stream)Builds the Responses body for <code class=“paramref”>modelId</code>. Generate calls omit stream.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string | |
options |
LanguageModelCallOptions | |
stream |
bool |
Returns: OpenAIResponsesPreparedRequest
Prepare(string, LanguageModelCallOptions, bool, string, bool)
Section titled “Prepare(string, LanguageModelCallOptions, bool, string, bool)”public static OpenAIResponsesPreparedRequest Prepare(string modelId, LanguageModelCallOptions options, bool stream, string providerOptionsName, bool supportsWebSearchSourcesInclude = true)Builds the Responses body. Options come from <code class=“paramref”>providerOptionsName</code> and fall back to
openai when that key is absent.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string | |
options |
LanguageModelCallOptions | |
stream |
bool | |
providerOptionsName |
string | |
supportsWebSearchSourcesInclude |
bool |
Returns: OpenAIResponsesPreparedRequest
Prepare(string, LanguageModelCallOptions, bool, string, bool, string?)
Section titled “Prepare(string, LanguageModelCallOptions, bool, string, bool, string?)”public static OpenAIResponsesPreparedRequest Prepare(string modelId, LanguageModelCallOptions options, bool stream, string providerOptionsName, bool supportsWebSearchSourcesInclude, string? requestModelId)Builds the Responses body. <code class=“paramref”>modelId</code> drives capability detection and
<code class=“paramref”>requestModelId</code>, when set, is sent as the request model.
Parameters
| Name | Type | Description |
|---|---|---|
modelId |
string | |
options |
LanguageModelCallOptions | |
stream |
bool | |
providerOptionsName |
string | |
supportsWebSearchSourcesInclude |
bool | |
requestModelId |
string |
Returns: OpenAIResponsesPreparedRequest
PrepareResponsesTools(IReadOnlyList<LanguageModelTool>?, ToolChoice?, PrepareResponsesToolsOptions?)
Section titled “PrepareResponsesTools(IReadOnlyList<LanguageModelTool>?, ToolChoice?, PrepareResponsesToolsOptions?)”public static PreparedResponsesTools PrepareResponsesTools(IReadOnlyList<LanguageModelTool>? tools, ToolChoice? toolChoice, PrepareResponsesToolsOptions? options = null)Prepares Responses tools and the tool choice. Strict is false unless the tool sets Strict.
Maps to prepareResponsesTools.
Parameters
| Name | Type | Description |
|---|---|---|
tools |
IReadOnlyList<LanguageModelTool> | |
toolChoice |
ToolChoice | |
options |
PrepareResponsesToolsOptions |
Returns: PreparedResponsesTools
Exceptions
| Type | Condition |
|---|---|
| TypeValidationException | The arguments of a provider-defined tool are invalid. |
| UnsupportedFunctionalityException | The tools or the tool choice cannot be expressed for OpenAI. |
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product