Skip to main content

Overview

Available Operations

  • Send - Create a chat completion

Send

Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.

Example Usage: guardrail-blocked

Example Usage: insufficient-permissions

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context:heavy_check_mark:The context to use for the request.
chatRequestcomponents.ChatRequest:heavy_check_mark:N/A{
“max_tokens”: 150,
“messages”: [
{
“content”: “You are a helpful assistant.”,
“role”: “system”
},
{
“content”: “What is the capital of France?”,
“role”: “user”
}
],
“model”: “openai/gpt-4”,
“temperature”: 0.7
}
xOpenRouterMetadata*components.MetadataLevel:heavy_minus_sign:Opt-in to surface routing metadata on the response under openrouter_metadata. Defaults to disabled. The legacy header X-OpenRouter-Experimental-Metadata is also accepted for backward compatibility.enabled
opts[]operations.Option:heavy_minus_sign:The options for this request.

Response

*operations.SendChatCompletionRequestResponse, error

Errors

Error TypeStatus CodeContent Type
sdkerrors.BadRequestResponseError400application/json
sdkerrors.UnauthorizedResponseError401application/json
sdkerrors.PaymentRequiredResponseError402application/json
sdkerrors.ForbiddenResponseError403application/json
sdkerrors.NotFoundResponseError404application/json
sdkerrors.RequestTimeoutResponseError408application/json
sdkerrors.PayloadTooLargeResponseError413application/json
sdkerrors.UnprocessableEntityResponseError422application/json
sdkerrors.TooManyRequestsResponseError429application/json
sdkerrors.InternalServerResponseError500application/json
sdkerrors.BadGatewayResponseError502application/json
sdkerrors.ServiceUnavailableResponseError503application/json
sdkerrors.EdgeNetworkTimeoutResponseError524application/json
sdkerrors.ProviderOverloadedResponseError529application/json
sdkerrors.APIError4XX, 5XX*/*