| POST | /v1/chat/completions |
|---|
import java.math.*;
import java.util.*;
import java.io.InputStream;
import net.servicestack.client.*;
import com.google.gson.annotations.*;
import com.google.gson.reflect.*;
public class dtos
{
/**
* Chat Completions API (OpenAI-Compatible)
*/
@DataContract
public static class ChatCompletion implements IPost
{
/**
* The messages to generate chat completions for.
*/
@DataMember(Name="messages")
@SerializedName("messages")
public ArrayList<AiMessage> messages = new ArrayList<AiMessage>();
/**
* ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API
*/
@DataMember(Name="model")
@SerializedName("model")
public String model = null;
/**
* Parameters for audio output. Required when audio output is requested with modalities: [audio]
*/
@DataMember(Name="audio")
@SerializedName("audio")
public AiChatAudio audio = null;
/**
* Modify the likelihood of specified tokens appearing in the completion.
*/
@DataMember(Name="logit_bias")
@SerializedName("logit_bias")
public HashMap<Integer,Integer> logitBias = null;
/**
* 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.
*/
@DataMember(Name="metadata")
@SerializedName("metadata")
public HashMap<String,String> metadata = null;
/**
* Constrains effort on reasoning for reasoning models. Currently supported values are minimal, low, medium, and high (none, default). Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
*/
@DataMember(Name="reasoning_effort")
@SerializedName("reasoning_effort")
public String reasoningEffort = null;
/**
* An object specifying the format that the model must output. Compatible with GPT-4 Turbo and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. Setting Type to ResponseFormat.JsonObject enables JSON mode, which guarantees the message the model generates is valid JSON.
*/
@DataMember(Name="response_format")
@SerializedName("response_format")
public AiResponseFormat responseFormat = null;
/**
* Specifies the processing type used for serving the request.
*/
@DataMember(Name="service_tier")
@SerializedName("service_tier")
public String serviceTier = null;
/**
* 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.
*/
@DataMember(Name="safety_identifier")
@SerializedName("safety_identifier")
public String safetyIdentifier = null;
/**
* Up to 4 sequences where the API will stop generating further tokens.
*/
@DataMember(Name="stop")
@SerializedName("stop")
public ArrayList<String> stop = null;
/**
* Output types that you would like the model to generate. Most models are capable of generating text, which is the default:
*/
@DataMember(Name="modalities")
@SerializedName("modalities")
public ArrayList<String> modalities = null;
/**
* Used by OpenAI to cache responses for similar requests to optimize your cache hit rates.
*/
@DataMember(Name="prompt_cache_key")
@SerializedName("prompt_cache_key")
public String promptCacheKey = null;
/**
* A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.
*/
@DataMember(Name="tools")
@SerializedName("tools")
public ArrayList<Tool> tools = null;
/**
* 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.
*/
@DataMember(Name="verbosity")
@SerializedName("verbosity")
public String verbosity = null;
/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
*/
@DataMember(Name="temperature")
@SerializedName("temperature")
public Double temperature = null;
/**
* An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
*/
@DataMember(Name="max_completion_tokens")
@SerializedName("max_completion_tokens")
public Integer maxCompletionTokens = null;
/**
* An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.
*/
@DataMember(Name="top_logprobs")
@SerializedName("top_logprobs")
public Integer topLogprobs = null;
/**
* An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
*/
@DataMember(Name="top_p")
@SerializedName("top_p")
public Double topP = null;
/**
* Number between `-2.0` and `2.0`. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
*/
@DataMember(Name="frequency_penalty")
@SerializedName("frequency_penalty")
public Double frequencyPenalty = null;
/**
* Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
*/
@DataMember(Name="presence_penalty")
@SerializedName("presence_penalty")
public Double presencePenalty = null;
/**
* This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed, and you should refer to the system_fingerprint response parameter to monitor changes in the backend.
*/
@DataMember(Name="seed")
@SerializedName("seed")
public Integer seed = null;
/**
* How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs.
*/
@DataMember(Name="n")
@SerializedName("n")
public Integer n = null;
/**
* Whether or not to store the output of this chat completion request for use in our model distillation or evals products.
*/
@DataMember(Name="store")
@SerializedName("store")
public Boolean store = null;
/**
* Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.
*/
@DataMember(Name="logprobs")
@SerializedName("logprobs")
public Boolean logprobs = null;
/**
* Whether to enable parallel function calling during tool use.
*/
@DataMember(Name="parallel_tool_calls")
@SerializedName("parallel_tool_calls")
public Boolean parallelToolCalls = null;
/**
* Whether to enable thinking mode for some Qwen models and providers.
*/
@DataMember(Name="enable_thinking")
@SerializedName("enable_thinking")
public Boolean enableThinking = null;
/**
* If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a `data: [DONE]` message.
*/
@DataMember(Name="stream")
@SerializedName("stream")
public Boolean stream = null;
public ArrayList<AiMessage> getMessages() { return messages; }
public ChatCompletion setMessages(ArrayList<AiMessage> value) { this.messages = value; return this; }
public String getModel() { return model; }
public ChatCompletion setModel(String value) { this.model = value; return this; }
public AiChatAudio getAudio() { return audio; }
public ChatCompletion setAudio(AiChatAudio value) { this.audio = value; return this; }
public HashMap<Integer,Integer> getLogitBias() { return logitBias; }
public ChatCompletion setLogitBias(HashMap<Integer,Integer> value) { this.logitBias = value; return this; }
public HashMap<String,String> getMetadata() { return metadata; }
public ChatCompletion setMetadata(HashMap<String,String> value) { this.metadata = value; return this; }
public String getReasoningEffort() { return reasoningEffort; }
public ChatCompletion setReasoningEffort(String value) { this.reasoningEffort = value; return this; }
public AiResponseFormat getResponseFormat() { return responseFormat; }
public ChatCompletion setResponseFormat(AiResponseFormat value) { this.responseFormat = value; return this; }
public String getServiceTier() { return serviceTier; }
public ChatCompletion setServiceTier(String value) { this.serviceTier = value; return this; }
public String getSafetyIdentifier() { return safetyIdentifier; }
public ChatCompletion setSafetyIdentifier(String value) { this.safetyIdentifier = value; return this; }
public ArrayList<String> getStop() { return stop; }
public ChatCompletion setStop(ArrayList<String> value) { this.stop = value; return this; }
public ArrayList<String> getModalities() { return modalities; }
public ChatCompletion setModalities(ArrayList<String> value) { this.modalities = value; return this; }
public String getPromptCacheKey() { return promptCacheKey; }
public ChatCompletion setPromptCacheKey(String value) { this.promptCacheKey = value; return this; }
public ArrayList<Tool> getTools() { return tools; }
public ChatCompletion setTools(ArrayList<Tool> value) { this.tools = value; return this; }
public String getVerbosity() { return verbosity; }
public ChatCompletion setVerbosity(String value) { this.verbosity = value; return this; }
public Double getTemperature() { return temperature; }
public ChatCompletion setTemperature(Double value) { this.temperature = value; return this; }
public Integer getMaxCompletionTokens() { return maxCompletionTokens; }
public ChatCompletion setMaxCompletionTokens(Integer value) { this.maxCompletionTokens = value; return this; }
public Integer getTopLogprobs() { return topLogprobs; }
public ChatCompletion setTopLogprobs(Integer value) { this.topLogprobs = value; return this; }
public Double getTopP() { return topP; }
public ChatCompletion setTopP(Double value) { this.topP = value; return this; }
public Double getFrequencyPenalty() { return frequencyPenalty; }
public ChatCompletion setFrequencyPenalty(Double value) { this.frequencyPenalty = value; return this; }
public Double getPresencePenalty() { return presencePenalty; }
public ChatCompletion setPresencePenalty(Double value) { this.presencePenalty = value; return this; }
public Integer getSeed() { return seed; }
public ChatCompletion setSeed(Integer value) { this.seed = value; return this; }
public Integer getN() { return n; }
public ChatCompletion setN(Integer value) { this.n = value; return this; }
public Boolean isStore() { return store; }
public ChatCompletion setStore(Boolean value) { this.store = value; return this; }
public Boolean isLogprobs() { return logprobs; }
public ChatCompletion setLogprobs(Boolean value) { this.logprobs = value; return this; }
public Boolean isParallelToolCalls() { return parallelToolCalls; }
public ChatCompletion setParallelToolCalls(Boolean value) { this.parallelToolCalls = value; return this; }
public Boolean isEnableThinking() { return enableThinking; }
public ChatCompletion setEnableThinking(Boolean value) { this.enableThinking = value; return this; }
public Boolean isStream() { return stream; }
public ChatCompletion setStream(Boolean value) { this.stream = value; return this; }
}
/**
* A list of messages comprising the conversation so far.
*/
@DataContract
public static class AiMessage
{
/**
* The contents of the message.
*/
@DataMember(Name="content")
@SerializedName("content")
public ArrayList<AiContent> content = null;
/**
* The role of the author of this message. Valid values are `system`, `user`, `assistant` and `tool`.
*/
@DataMember(Name="role")
@SerializedName("role")
public String role = null;
/**
* An optional name for the participant. Provides the model information to differentiate between participants of the same role.
*/
@DataMember(Name="name")
@SerializedName("name")
public String name = null;
/**
* The tool calls generated by the model, such as function calls.
*/
@DataMember(Name="tool_calls")
@SerializedName("tool_calls")
public ArrayList<ToolCall> toolCalls = null;
/**
* Tool call that this message is responding to.
*/
@DataMember(Name="tool_call_id")
@SerializedName("tool_call_id")
public String toolCallId = null;
public ArrayList<AiContent> getContent() { return content; }
public AiMessage setContent(ArrayList<AiContent> value) { this.content = value; return this; }
public String getRole() { return role; }
public AiMessage setRole(String value) { this.role = value; return this; }
public String getName() { return name; }
public AiMessage setName(String value) { this.name = value; return this; }
public ArrayList<ToolCall> getToolCalls() { return toolCalls; }
public AiMessage setToolCalls(ArrayList<ToolCall> value) { this.toolCalls = value; return this; }
public String getToolCallId() { return toolCallId; }
public AiMessage setToolCallId(String value) { this.toolCallId = value; return this; }
}
@DataContract
public static class AiContent
{
/**
* The type of the content part.
*/
@DataMember(Name="type")
@SerializedName("type")
public String type = null;
public String getType() { return type; }
public AiContent setType(String value) { this.type = value; return this; }
}
/**
* The tool calls generated by the model, such as function calls.
*/
@DataContract
public static class ToolCall
{
/**
* The ID of the tool call.
*/
@DataMember(Name="id")
@SerializedName("id")
public String id = null;
/**
* The type of the tool. Currently, only `function` is supported.
*/
@DataMember(Name="type")
@SerializedName("type")
public String type = null;
/**
* The function that the model called.
*/
@DataMember(Name="function")
@SerializedName("function")
public String function = null;
public String getId() { return id; }
public ToolCall setId(String value) { this.id = value; return this; }
public String getType() { return type; }
public ToolCall setType(String value) { this.type = value; return this; }
public String getFunction() { return function; }
public ToolCall setFunction(String value) { this.function = value; return this; }
}
/**
* Parameters for audio output. Required when audio output is requested with modalities: [audio]
*/
@DataContract
public static class AiChatAudio
{
/**
* Specifies the output audio format. Must be one of wav, mp3, flac, opus, or pcm16.
*/
@DataMember(Name="format")
@SerializedName("format")
public String format = null;
/**
* The voice the model uses to respond. Supported voices are alloy, ash, ballad, coral, echo, fable, nova, onyx, sage, and shimmer.
*/
@DataMember(Name="voice")
@SerializedName("voice")
public String voice = null;
public String getFormat() { return format; }
public AiChatAudio setFormat(String value) { this.format = value; return this; }
public String getVoice() { return voice; }
public AiChatAudio setVoice(String value) { this.voice = value; return this; }
}
@DataContract
public static class AiResponseFormat
{
/**
* An object specifying the format that the model must output. Compatible with GPT-4 Turbo and all GPT-3.5 Turbo models newer than gpt-3.5-turbo-1106.
*/
@DataMember(Name="response_format")
@SerializedName("response_format")
public ResponseFormat type = null;
public ResponseFormat getType() { return type; }
public AiResponseFormat setType(ResponseFormat value) { this.type = value; return this; }
}
public static enum ResponseFormat
{
Text,
JsonObject;
}
@DataContract
public static class Tool
{
/**
* The type of the tool. Currently, only function is supported.
*/
@DataMember(Name="type")
@SerializedName("type")
public ToolType type = null;
public ToolType getType() { return type; }
public Tool setType(ToolType value) { this.type = value; return this; }
}
public static enum ToolType
{
Function;
}
@DataContract
public static class ChatResponse
{
/**
* A unique identifier for the chat completion.
*/
@DataMember(Name="id")
@SerializedName("id")
public String id = null;
/**
* A list of chat completion choices. Can be more than one if n is greater than 1.
*/
@DataMember(Name="choices")
@SerializedName("choices")
public ArrayList<Choice> choices = new ArrayList<Choice>();
/**
* The Unix timestamp (in seconds) of when the chat completion was created.
*/
@DataMember(Name="created")
@SerializedName("created")
public Long created = null;
/**
* The model used for the chat completion.
*/
@DataMember(Name="model")
@SerializedName("model")
public String model = null;
/**
* This fingerprint represents the backend configuration that the model runs with.
*/
@DataMember(Name="system_fingerprint")
@SerializedName("system_fingerprint")
public String systemFingerprint = null;
/**
* The object type, which is always chat.completion.
*/
@DataMember(Name="object")
@SerializedName("object")
public String object = null;
/**
* Specifies the processing type used for serving the request.
*/
@DataMember(Name="service_tier")
@SerializedName("service_tier")
public String serviceTier = null;
/**
* Usage statistics for the completion request.
*/
@DataMember(Name="usage")
@SerializedName("usage")
public AiUsage usage = null;
/**
* The provider used for the chat completion.
*/
@DataMember(Name="provider")
@SerializedName("provider")
public String provider = null;
/**
* 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.
*/
@DataMember(Name="metadata")
@SerializedName("metadata")
public HashMap<String,String> metadata = null;
@DataMember(Name="responseStatus")
@SerializedName("responseStatus")
public ResponseStatus responseStatus = null;
public String getId() { return id; }
public ChatResponse setId(String value) { this.id = value; return this; }
public ArrayList<Choice> getChoices() { return choices; }
public ChatResponse setChoices(ArrayList<Choice> value) { this.choices = value; return this; }
public Long getCreated() { return created; }
public ChatResponse setCreated(Long value) { this.created = value; return this; }
public String getModel() { return model; }
public ChatResponse setModel(String value) { this.model = value; return this; }
public String getSystemFingerprint() { return systemFingerprint; }
public ChatResponse setSystemFingerprint(String value) { this.systemFingerprint = value; return this; }
public String getObject() { return object; }
public ChatResponse setObject(String value) { this.object = value; return this; }
public String getServiceTier() { return serviceTier; }
public ChatResponse setServiceTier(String value) { this.serviceTier = value; return this; }
public AiUsage getUsage() { return usage; }
public ChatResponse setUsage(AiUsage value) { this.usage = value; return this; }
public String getProvider() { return provider; }
public ChatResponse setProvider(String value) { this.provider = value; return this; }
public HashMap<String,String> getMetadata() { return metadata; }
public ChatResponse setMetadata(HashMap<String,String> value) { this.metadata = value; return this; }
public ResponseStatus getResponseStatus() { return responseStatus; }
public ChatResponse setResponseStatus(ResponseStatus value) { this.responseStatus = value; return this; }
}
@DataContract
public static class Choice
{
/**
* The reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence, length if the maximum number of tokens specified in the request was reached, content_filter if content was omitted due to a flag from our content filters, tool_calls if the model called a tool
*/
@DataMember(Name="finish_reason")
@SerializedName("finish_reason")
public String finishReason = null;
/**
* The index of the choice in the list of choices.
*/
@DataMember(Name="index")
@SerializedName("index")
public Integer index = null;
/**
* A chat completion message generated by the model.
*/
@DataMember(Name="message")
@SerializedName("message")
public ChoiceMessage message = null;
public String getFinishReason() { return finishReason; }
public Choice setFinishReason(String value) { this.finishReason = value; return this; }
public Integer getIndex() { return index; }
public Choice setIndex(Integer value) { this.index = value; return this; }
public ChoiceMessage getMessage() { return message; }
public Choice setMessage(ChoiceMessage value) { this.message = value; return this; }
}
@DataContract
public static class ChoiceMessage
{
/**
* The contents of the message.
*/
@DataMember(Name="content")
@SerializedName("content")
public String content = null;
/**
* The refusal message generated by the model.
*/
@DataMember(Name="refusal")
@SerializedName("refusal")
public String refusal = null;
/**
* The reasoning process used by the model.
*/
@DataMember(Name="reasoning")
@SerializedName("reasoning")
public String reasoning = null;
/**
* The role of the author of this message.
*/
@DataMember(Name="role")
@SerializedName("role")
public String role = null;
/**
* Annotations for the message, when applicable, as when using the web search tool.
*/
@DataMember(Name="annotations")
@SerializedName("annotations")
public ArrayList<ChoiceAnnotation> annotations = null;
/**
* If the audio output modality is requested, this object contains data about the audio response from the model.
*/
@DataMember(Name="audio")
@SerializedName("audio")
public ChoiceAudio audio = null;
/**
* The tool calls generated by the model, such as function calls.
*/
@DataMember(Name="tool_calls")
@SerializedName("tool_calls")
public ArrayList<ToolCall> toolCalls = null;
public String getContent() { return content; }
public ChoiceMessage setContent(String value) { this.content = value; return this; }
public String getRefusal() { return refusal; }
public ChoiceMessage setRefusal(String value) { this.refusal = value; return this; }
public String getReasoning() { return reasoning; }
public ChoiceMessage setReasoning(String value) { this.reasoning = value; return this; }
public String getRole() { return role; }
public ChoiceMessage setRole(String value) { this.role = value; return this; }
public ArrayList<ChoiceAnnotation> getAnnotations() { return annotations; }
public ChoiceMessage setAnnotations(ArrayList<ChoiceAnnotation> value) { this.annotations = value; return this; }
public ChoiceAudio getAudio() { return audio; }
public ChoiceMessage setAudio(ChoiceAudio value) { this.audio = value; return this; }
public ArrayList<ToolCall> getToolCalls() { return toolCalls; }
public ChoiceMessage setToolCalls(ArrayList<ToolCall> value) { this.toolCalls = value; return this; }
}
/**
* Annotations for the message, when applicable, as when using the web search tool.
*/
@DataContract
public static class ChoiceAnnotation
{
/**
* The type of the URL citation. Always url_citation.
*/
@DataMember(Name="type")
@SerializedName("type")
public String type = null;
/**
* A URL citation when using web search.
*/
@DataMember(Name="url_citation")
@SerializedName("url_citation")
public UrlCitation urlCitation = null;
public String getType() { return type; }
public ChoiceAnnotation setType(String value) { this.type = value; return this; }
public UrlCitation getUrlCitation() { return urlCitation; }
public ChoiceAnnotation setUrlCitation(UrlCitation value) { this.urlCitation = value; return this; }
}
/**
* Annotations for the message, when applicable, as when using the web search tool.
*/
@DataContract
public static class UrlCitation
{
/**
* The index of the last character of the URL citation in the message.
*/
@DataMember(Name="end_index")
@SerializedName("end_index")
public Integer endIndex = null;
/**
* The index of the first character of the URL citation in the message.
*/
@DataMember(Name="start_index")
@SerializedName("start_index")
public Integer startIndex = null;
/**
* The title of the web resource.
*/
@DataMember(Name="title")
@SerializedName("title")
public String title = null;
/**
* The URL of the web resource.
*/
@DataMember(Name="url")
@SerializedName("url")
public String url = null;
public Integer getEndIndex() { return endIndex; }
public UrlCitation setEndIndex(Integer value) { this.endIndex = value; return this; }
public Integer getStartIndex() { return startIndex; }
public UrlCitation setStartIndex(Integer value) { this.startIndex = value; return this; }
public String getTitle() { return title; }
public UrlCitation setTitle(String value) { this.title = value; return this; }
public String getUrl() { return url; }
public UrlCitation setUrl(String value) { this.url = value; return this; }
}
/**
* If the audio output modality is requested, this object contains data about the audio response from the model.
*/
@DataContract
public static class ChoiceAudio
{
/**
* Base64 encoded audio bytes generated by the model, in the format specified in the request.
*/
@DataMember(Name="data")
@SerializedName("data")
public String data = null;
/**
* The Unix timestamp (in seconds) for when this audio response will no longer be accessible on the server for use in multi-turn conversations.
*/
@DataMember(Name="expires_at")
@SerializedName("expires_at")
public Integer expiresAt = null;
/**
* Unique identifier for this audio response.
*/
@DataMember(Name="id")
@SerializedName("id")
public String id = null;
/**
* Transcript of the audio generated by the model.
*/
@DataMember(Name="transcript")
@SerializedName("transcript")
public String transcript = null;
public String getData() { return data; }
public ChoiceAudio setData(String value) { this.data = value; return this; }
public Integer getExpiresAt() { return expiresAt; }
public ChoiceAudio setExpiresAt(Integer value) { this.expiresAt = value; return this; }
public String getId() { return id; }
public ChoiceAudio setId(String value) { this.id = value; return this; }
public String getTranscript() { return transcript; }
public ChoiceAudio setTranscript(String value) { this.transcript = value; return this; }
}
/**
* Usage statistics for the completion request.
*/
@DataContract
public static class AiUsage
{
/**
* Number of tokens in the generated completion.
*/
@DataMember(Name="completion_tokens")
@SerializedName("completion_tokens")
public Integer completionTokens = null;
/**
* Number of tokens in the prompt.
*/
@DataMember(Name="prompt_tokens")
@SerializedName("prompt_tokens")
public Integer promptTokens = null;
/**
* Total number of tokens used in the request (prompt + completion).
*/
@DataMember(Name="total_tokens")
@SerializedName("total_tokens")
public Integer totalTokens = null;
/**
* Breakdown of tokens used in a completion.
*/
@DataMember(Name="completion_tokens_details")
@SerializedName("completion_tokens_details")
public AiCompletionUsage completionTokensDetails = null;
/**
* Breakdown of tokens used in the prompt.
*/
@DataMember(Name="prompt_tokens_details")
@SerializedName("prompt_tokens_details")
public AiPromptUsage promptTokensDetails = null;
public Integer getCompletionTokens() { return completionTokens; }
public AiUsage setCompletionTokens(Integer value) { this.completionTokens = value; return this; }
public Integer getPromptTokens() { return promptTokens; }
public AiUsage setPromptTokens(Integer value) { this.promptTokens = value; return this; }
public Integer getTotalTokens() { return totalTokens; }
public AiUsage setTotalTokens(Integer value) { this.totalTokens = value; return this; }
public AiCompletionUsage getCompletionTokensDetails() { return completionTokensDetails; }
public AiUsage setCompletionTokensDetails(AiCompletionUsage value) { this.completionTokensDetails = value; return this; }
public AiPromptUsage getPromptTokensDetails() { return promptTokensDetails; }
public AiUsage setPromptTokensDetails(AiPromptUsage value) { this.promptTokensDetails = value; return this; }
}
/**
* Usage statistics for the completion request.
*/
@DataContract
public static class AiCompletionUsage
{
/**
* When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
*/
@DataMember(Name="accepted_prediction_tokens")
@SerializedName("accepted_prediction_tokens")
public Integer acceptedPredictionTokens = null;
/**
* Audio input tokens generated by the model.
*/
@DataMember(Name="audio_tokens")
@SerializedName("audio_tokens")
public Integer audioTokens = null;
/**
* Tokens generated by the model for reasoning.
*/
@DataMember(Name="reasoning_tokens")
@SerializedName("reasoning_tokens")
public Integer reasoningTokens = null;
/**
* When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion.
*/
@DataMember(Name="rejected_prediction_tokens")
@SerializedName("rejected_prediction_tokens")
public Integer rejectedPredictionTokens = null;
public Integer getAcceptedPredictionTokens() { return acceptedPredictionTokens; }
public AiCompletionUsage setAcceptedPredictionTokens(Integer value) { this.acceptedPredictionTokens = value; return this; }
public Integer getAudioTokens() { return audioTokens; }
public AiCompletionUsage setAudioTokens(Integer value) { this.audioTokens = value; return this; }
public Integer getReasoningTokens() { return reasoningTokens; }
public AiCompletionUsage setReasoningTokens(Integer value) { this.reasoningTokens = value; return this; }
public Integer getRejectedPredictionTokens() { return rejectedPredictionTokens; }
public AiCompletionUsage setRejectedPredictionTokens(Integer value) { this.rejectedPredictionTokens = value; return this; }
}
/**
* Breakdown of tokens used in the prompt.
*/
@DataContract
public static class AiPromptUsage
{
/**
* When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
*/
@DataMember(Name="accepted_prediction_tokens")
@SerializedName("accepted_prediction_tokens")
public Integer acceptedPredictionTokens = null;
/**
* Audio input tokens present in the prompt.
*/
@DataMember(Name="audio_tokens")
@SerializedName("audio_tokens")
public Integer audioTokens = null;
/**
* Cached tokens present in the prompt.
*/
@DataMember(Name="cached_tokens")
@SerializedName("cached_tokens")
public Integer cachedTokens = null;
public Integer getAcceptedPredictionTokens() { return acceptedPredictionTokens; }
public AiPromptUsage setAcceptedPredictionTokens(Integer value) { this.acceptedPredictionTokens = value; return this; }
public Integer getAudioTokens() { return audioTokens; }
public AiPromptUsage setAudioTokens(Integer value) { this.audioTokens = value; return this; }
public Integer getCachedTokens() { return cachedTokens; }
public AiPromptUsage setCachedTokens(Integer value) { this.cachedTokens = value; return this; }
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /v1/chat/completions HTTP/1.1
Host: blazor-vue.web-templates.io
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
messages:
[
{
content:
[
{
}
],
role: String,
name: String,
tool_calls:
[
{
id: String,
type: String,
function: String
}
],
tool_call_id: String
}
],
model: String,
audio:
{
format: String,
voice: String
},
logit_bias:
{
0: 0
},
metadata:
{
String: String
},
reasoning_effort: String,
response_format:
{
response_format: text
},
service_tier: String,
safety_identifier: String,
stop:
[
String
],
modalities:
[
String
],
prompt_cache_key: String,
tools:
[
{
type: function
}
],
verbosity: String,
temperature: 0,
max_completion_tokens: 0,
top_logprobs: 0,
top_p: 0,
frequency_penalty: 0,
presence_penalty: 0,
seed: 0,
n: 0,
store: False,
logprobs: False,
parallel_tool_calls: False,
enable_thinking: False,
stream: False
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
id: String,
choices:
[
{
finish_reason: String,
index: 0,
message:
{
content: String,
refusal: String,
reasoning: String,
role: String,
annotations:
[
{
type: String,
url_citation:
{
end_index: 0,
start_index: 0,
title: String,
url: String
}
}
],
audio:
{
data: String,
expires_at: 0,
id: String,
transcript: String
},
tool_calls:
[
{
id: String,
type: String,
function: String
}
]
}
}
],
created: 0,
model: String,
system_fingerprint: String,
object: String,
service_tier: String,
usage:
{
completion_tokens: 0,
prompt_tokens: 0,
total_tokens: 0,
completion_tokens_details:
{
accepted_prediction_tokens: 0,
audio_tokens: 0,
reasoning_tokens: 0,
rejected_prediction_tokens: 0
},
prompt_tokens_details:
{
accepted_prediction_tokens: 0,
audio_tokens: 0,
cached_tokens: 0
}
},
provider: String,
metadata:
{
String: String
},
responseStatus:
{
errorCode: String,
message: String,
stackTrace: String,
errors:
[
{
errorCode: String,
fieldName: String,
message: String,
meta:
{
String: String
}
}
],
meta:
{
String: String
}
}
}