OhMyGPT
Chat

Create chat completion

POST
/v1/chat/completions

OpenAI-compatible Chat Completions endpoint for 270+ models. Provider-native parameters (thinking, reasoning_effort, etc.) are passed through to the serving provider unchanged.

授权

ApiKeyAuth
headerAuthorization<token>

请求主体

application/json
  1. body
metadata?|null
prompt_cache_key?string

Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the user field. Learn more.

prompt_cache_retention?|null
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.

长度length <= 64
service_tier?|null
temperature?|null
top_logprobs?
top_p?|null
user?string已弃用

This field is being replaced by safety_identifier and prompt_cache_key. Use prompt_cache_key instead 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.

audio?

Parameters for audio output. Required when audio output is requested with modalities: ["audio"]. Learn more.

frequency_penalty?number

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.

范围-2 <= value <= 2
默认0
function_call?|已弃用

Deprecated in favor of tool_choice.

Controls which (if any) function is called by the model.

none means the model will not call a function and instead generates a message.

auto means the model can pick between generating a message or calling a function.

Specifying a particular function via {"name": "my_function"} forces the model to call that function.

none is the default when no functions are present. auto is the default if functions are present.

functions?array<>已弃用

Deprecated in favor of tools.

A list of functions the model may generate JSON inputs for.

项目1 <= items <= 128
logit_bias?

Modify the likelihood of specified tokens appearing in the completion.

Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.

默认null
logprobs?boolean

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.

默认false
max_completion_tokens?integer

An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.

max_tokens?integer已弃用

The maximum number of tokens that can be generated in the chat completion. This value controls the maximum generated tokens.

This value is now deprecated in favor of max_completion_tokens, and is not compatible with o-series models.

messages*array<|||||>

A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, images, and audio.

项目1 <= items
modalities?array<>|null
model*|

Model ID used to generate the response, like gpt-4o or o3. OpenAI offers a wide range of models with different capabilities, performance characteristics, and latency profiles. Refer to the model guide to browse and compare available models.

n?integer

How many chat completion choices to generate for each input message. Higher values can generate more output tokens.

范围1 <= value <= 128
默认1
parallel_tool_calls?ParallelToolCalls

Whether to enable parallel function calling during tool use.

默认true
prediction?

Configuration for a Predicted Output, which can greatly improve response times when large parts of the model response are known ahead of time. This is most common when you are regenerating a file with only minor changes to most of the content.

presence_penalty?number

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.

范围-2 <= value <= 2
默认0
reasoning_effort?|null
response_format?||

An object specifying the format that the model must output.

Setting to { "type": "json_schema", "json_schema": {...} } enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the Structured Outputs guide.

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.

seed?integer已弃用

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.

范围-9223372036854776000 <= value <= 9223372036854776000
stop?|array<string>

Not supported with latest reasoning models o3 and o4-mini.

Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.

默认null
store?boolean

Whether or not to store the output of this chat completion request for use in our model distillation or evals products.

Supports text and image inputs. Note: image inputs over 8MB will be dropped.

默认false
stream?boolean

If set to true, the model response data will be streamed to the client as it is generated using server-sent events. See the Streaming section below for more information, along with the streaming responses guide for more information on how to handle the streaming events.

默认false
stream_options?|null
tool_choice?|||

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. Specifying a particular tool via {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool.

none is the default when no tools are present. auto is the default if tools are present.

tools?array<|>

A list of tools the model may call. You can provide either custom tools or function tools.

verbosity?|null
web_search_options?

This tool searches the web for relevant results to use in a response. Learn more about the web search tool.

响应主体

Successful response

application/json
  1. response

Represents a chat completion response returned by model, based on the provided input.

choices*array<>

A list of chat completion choices. Can be more than one if n is greater than 1.

created*integer

The Unix timestamp (in seconds) of when the chat completion was created.

id*string

A unique identifier for the chat completion.

model*string

The model used for the chat completion.

object*"chat.completion"

The object type, which is always chat.completion.

值于"chat.completion"
service_tier?|null
system_fingerprint?string已弃用

This fingerprint represents the backend configuration that the model runs with.

Can be used in conjunction with the seed request parameter to understand when backend changes have been made that might impact determinism.

usage?

What this request cost. All amounts are in Credits, not USD.

provider?string

The provider that served the request.

示例请求
curl -X POST 'https://api.ohmygpt.com/v1/chat/completions' \  -H 'Content-Type: application/json' \  -d '{  "messages": [    {      "content": "string",      "role": "developer"    }  ],  "model": "string"}'
示例响应
{  "created": 0,  "id": "string",  "model": "string",  "object": "chat.completion",  "service_tier": "auto",  "system_fingerprint": "string",  "provider": "string",  "usage": {    "completion_tokens": 0,    "completion_tokens_details": {      "accepted_prediction_tokens": 0,      "audio_tokens": 0,      "reasoning_tokens": 0,      "rejected_prediction_tokens": 0    },    "prompt_tokens": 0,    "prompt_tokens_details": {      "audio_tokens": 0,      "cached_tokens": 0    },    "total_tokens": 0,    "billing_mode": "platform",    "cost": 0,    "is_byok": true  },  "choices": [    {      "native_finish_reason": "string"    }  ]}