1. Completions
梧柏API使用文档
WHBAI · OpenAI 兼容
  • WHBAI · Google Gemini 原生 (v1alpha)
  • WHBAI · Google Gemini 原生
  • WHBAI · Ideogram
  • WHBAI · Ideogram V3
  • WHBAI · Midjourney
  • WHBAI · Jimeng
  • WHBAI · Kling
  • WHBAI · Luma
  • WHBAI · Luma V1
  • WHBAI · Omni 视频
  • WHBAI · Pixverse
  • WHBAI · Runway
  • WHBAI · Sora2
  • WHBAI · 统一视频 VEO
  • WHBAI · Vidu
  • WHBAI · 豆包 Volc
  • WHBAI · Suno
  • WHBAI · Playground
  • WHBAI · 账号与令牌
  • WHBAI · 阿里 Pix
  • WHBAI · 阿里百炼
  • WHBAI · 私域人像
  • WHBAI · Fal.ai
  • WHBAI · Replicate
  • WHBAI · 腾讯云 VOD
  • WHBAI · MiniMax
  • WHBAI · 支持模型列表
  • WHBAI · Grok Imagine
  • WHBAI · Seedance 2.0
  • WHBAI · TypeSafe
  • WHBAI · OpenAI 兼容
  • Chat
    • 对话补全(OpenAI 兼容)
      POST
  • Embeddings
    • 文本嵌入(OpenAI 兼容)
      POST
  • Audio
    • 音频转文字 gpt-4o-transcribe
      POST
    • 创建语音 gpt-4o-mini-tts
      POST
    • 创建翻译(部分模型不支持)
      POST
  • 文生图接口
    • GPT Image-1
      • 创建 gpt-image-2.5
    • Grok
      • 编辑image【"grok-imagine-image-quality" | "grok-imagine-image-2.0"】
  • Models
    • 获取令牌支持模型
      GET
  • Completions
    • 创建完成
      POST
  • Responses
    • 创建函数调用
      POST
    • gpt 上下文压缩
      POST
  • Rerank
    • 重排序
      POST
  • 智能交互
    • TypeSafe
      • TypeSafe System One
  • 谷歌Gemini
    • 原生格式
      • 图片生成 gemini-nano-banana-2.1
  • 品牌平台
    • MINIMAX-V2
      • 创建视频
      • 查询单个任务
  • 数据模型
    • 对话接口 POST /v1/chat/completions
    • V1ChatCompletionsResponse
    • V1EmbeddingsRequest
    • V1EmbeddingsResponse
    • V1AudioSpeechRequest
    • PostV1ImagesGenerationsRequest
    • POST /v1/images/generations · wan2.7-image-pro 成功响应
    • POSTV1ImagesGenerations_DallE2
    • POSTV1ImagesGenerations_GptImage1
    • POSTV1ImagesGenerations_GptImage2
    • POSTV1ImagesGenerations_GptImage25
    • POSTV1ImagesGenerations_GptImage2C
    • POSTV1ImagesGenerations_QwenImageMax
    • POSTV1ImagesGenerations_ZImageTurbo
    • POSTV1ImagesGenerations_QwenImage20260303
    • POSTV1ImagesGenerations_QwenImage3
    • POSTV1ImagesGenerations_QwenImage3Pro
    • POSTV1ImagesEdits_Grok3Image
    • POSTV1ImagesEdits_GptImage1
    • POSTV1ImagesEdits_GptImage2
    • POSTV1ImagesEdits_GptImage25
    • POSTV1ImagesEdits_QwenImageEdit2509
    • POSTV1ImagesGenerations_DallE3
    • POSTV1ImagesGenerations_Grok2Image
    • POSTV1ImagesGenerations_Grok3Image
    • Message
    • ContentPart
    • Tool
    • StreamOptions
    • ResponseFormat
    • WebSearchOptions
    • wan2.7-image-pro 文生图请求
    • imageData
    • PostV1ImagesEditsResponse
    • PostV1CompletionsRequest
    • PostV1CompletionsResponse
    • PostV1ResponsesRequest
    • PostV1ResponsesResponse
    • PostV1ResponsesCompactRequest
    • PostV1RerankRequest
    • PostV1RerankResponse
    • NewApiError
  1. Completions

创建完成

POST
/v1/completions
给定一个提示,该模型将返回一个或多个预测的完成,并且还可以返回每个位置的替代标记的概率。
为提供的提示和参数创建完成
https://platform.openai.com/docs/api-reference/completions

网站中的模型与调用示例#

创建完成#

给定一个提示,该模型将返回一个或多个预测的完成,并且还可以返回每个位置的替代标记的概率。
为提供的提示和参数创建完成
https://platform.openai.com/docs/api-reference/completions

请求参数#

{
  "contentType": "application/json",
  "properties": {
    "best_of": {
      "description": "默认为1 在服务器端生成best_of个补全,并返回“最佳”补全(每个令牌的日志概率最高的那个)。无法流式传输结果。  与n一起使用时,best_of控制候选补全的数量,n指定要返回的数量 – best_of必须大于n。  注意:因为这个参数会生成许多补全,所以它可以快速消耗您的令牌配额。请谨慎使用,并确保您对max_tokens和stop有合理的设置。",
      "type": "integer",
      "x-i18n": {
        "en-US": {
          "description": "Defaults to 1 Generate best_of completions on the server side and return the \"best\" completion (the one with the highest log probability for each token). Unable to stream results.  When used with n, best_of controls the number of candidate completions, and n specifies the number to return – best_of must be greater than n.  Note: Because this parameter generates many completions, it can drain your token quota quickly. Please use with caution and make sure you have reasonable settings for max_tokens and stop."
        }
      }
    },
    "echo": {
      "description": "默认为false 除了补全之外,还回显提示",
      "type": "boolean",
      "x-i18n": {
        "en-US": {
          "description": "The default is false. In addition to completion, prompts are also echoed."
        }
      }
    },
    "frequency_penalty": {
      "description": "默认为0 -2.0和2.0之间的数字。正值根据文本目前的现有频率处罚新令牌,降低模型逐字重复相同行的可能性。",
      "type": "number",
      "x-i18n": {
        "en-US": {
          "description": "Defaults to 0 - a number between 2.0 and 2.0. Positive values ​​penalize new tokens based on the current existing frequency of the text, reducing the likelihood that the model will repeat the same line verbatim."
        }
      }
    },
    "logit_bias": {
      "description": "默认为null 修改完成中指定令牌出现的可能性。  接受一个JSON对象,该对象将令牌(由GPT令牌化器中的令牌ID指定)映射到关联偏差值,-100到100。您可以使用这个令牌化器工具(适用于GPT-2和GPT-3)将文本转换为令牌ID。从数学上讲,偏差在对模型进行采样之前添加到生成的logit中。确切效果因模型而异,但-1至1之间的值应降低或提高选择的可能性;像-100或100这样的值应导致相关令牌的禁用或专属选择。  例如,您可以传递{\"50256\": -100}来防止生成<|endoftext|>令牌。",
      "properties": {},
      "type": "object",
      "x-i18n": {
        "en-US": {
          "description": "Defaults to null The probability of occurrence of the specified token in modification completion.  Accepts a JSON object that maps a token (specified by the token ID in the GPT tokenizer) to an associated bias value, -100 to 100. You can use this tokenizer tool (available for GPT-2 and GPT-3) to convert text into token IDs. Mathematically speaking, the bias is added to the resulting logit before sampling the model. The exact effect varies from model to model, but values ​​between -1 and 1 should reduce or increase the likelihood of selection; values ​​like -100 or 100 should result in a ban or exclusive selection of the token in question.  For example, you can pass {\"50256\": -100} to prevent the <|endoftext|> token from being generated."
        }
      }
    },
    "logprobs": {
      "description": "默认为null\n包括logprobs个最可能令牌的日志概率,以及所选令牌。例如,如果logprobs为5,API将返回5个最有可能令牌的列表。 API总会返回采样令牌的logprob,因此响应中最多可能有logprobs+1个元素。\n\nlogprobs的最大值是5。",
      "title": "",
      "type": "null",
      "x-i18n": {
        "en-US": {
          "description": "Default is null\nIncludes the log probabilities of the logprobs most likely tokens, as well as the selected token. For example, if logprobs is 5, the API will return a list of the 5 most likely tokens. The API always returns the logprob of the sampled token, so there may be at most logprobs+1 elements in the response.\n\nThe maximum value of logprobs is 5."
        }
      }
    },
    "max_tokens": {
      "description": "默认为16\n在补全中生成的最大令牌数。\n\n提示的令牌计数加上max_tokens不能超过模型的上下文长度。 计数令牌的Python代码示例。",
      "title": "",
      "type": "integer",
      "x-i18n": {
        "en-US": {
          "description": "Default is 16\nThe maximum number of tokens generated in completion.\n\nThe hint's token count plus max_tokens cannot exceed the model's context length. Python code example for counting tokens."
        }
      }
    },
    "model": {
      "description": "要使用的模型的 ID。您可以使用[List models](https://platform.openai.com/docs/api-reference/models/list) API 来查看所有可用模型,或查看我们的[模型概述](https://platform.openai.com/docs/models/overview)以了解它们的描述。",
      "title": "",
      "type": "string",
      "x-i18n": {
        "en-US": {
          "description": "The ID of the model to use. You can use the List models API to view all available models, or view our Model Overview for their descriptions."
        }
      }
    },
    "n": {
      "description": "默认为1\n为每个提示生成的补全数量。\n\n注意:因为这个参数会生成许多补全,所以它可以快速消耗您的令牌配额。请谨慎使用,并确保您对max_tokens和stop有合理的设置。",
      "type": "integer",
      "x-i18n": {
        "en-US": {
          "description": "Default is 1\nThe number of completions generated for each prompt.\n\nNote: Because this parameter generates many completions, it can drain your token quota quickly. Please use with caution and make sure you have reasonable settings for max_tokens and stop."
        }
      }
    },
    "presence_penalty": {
      "description": "默认为0 -2.0和2.0之间的数字。正值根据它们是否出现在目前的文本中来惩罚新令牌,增加模型讨论新话题的可能性。  有关频率和存在惩罚的更多信息,请参阅。",
      "type": "number",
      "x-i18n": {
        "en-US": {
          "description": "Defaults to 0 - a number between 2.0 and 2.0. Positive values ​​penalize new tokens based on whether they appear in the current text, increasing the likelihood that the model discusses new topics.  For more information on frequency and presence penalties, see ."
        }
      }
    },
    "prompt": {
      "description": "生成完成的提示,编码为字符串、字符串数组、标记数组或标记数组数组。  请注意,<|endoftext|> 是模型在训练期间看到的文档分隔符,因此如果未指定提示,模型将生成新文档的开头。",
      "title": "",
      "type": "string",
      "x-i18n": {
        "en-US": {
          "description": "Generates a completed prompt, encoded as a string, an array of strings, an array of tokens, or an array of token arrays.  Note that <|endoftext|> is the document delimiter that the model sees during training, so if no hints are specified, the model will generate the beginning of a new document."
        }
      }
    },
    "seed": {
      "description": "如果指定,我们的系统将尽最大努力确定性地进行采样,以便使用相同的种子和参数的重复请求应返回相同的结果。  不保证确定性,您应该参考system_fingerprint响应参数来监视后端的更改。",
      "type": "integer",
      "x-i18n": {
        "en-US": {
          "description": "If specified, our system will do its best to sample deterministically so that repeated requests with the same seed and parameters should return the same results.  Determinism is not guaranteed and you should refer to the system_fingerprint response parameter to monitor your backend for changes."
        }
      }
    },
    "stop": {
      "description": "默认为null 最多4个序列,API将停止在其中生成更多令牌。返回的文本不会包含停止序列。",
      "title": "",
      "type": "string",
      "x-i18n": {
        "en-US": {
          "description": "Defaults to null for a maximum of 4 sequences at which the API will stop generating more tokens. The text returned will not contain stop sequences."
        }
      }
    },
    "stream": {
      "description": "默认为false 是否流回部分进度。如果设置,令牌将作为可用时发送为仅数据的服务器发送事件,流由数据 Terminated by a data: [DONE] message. 对象消息终止。 Python代码示例。",
      "title": "",
      "type": "boolean",
      "x-i18n": {
        "en-US": {
          "description": "The default is false whether to flow back part of the progress. If set, the token will be sent as a data-only server-sent event when available, and the stream is terminated by a data: [DONE] message. Object message. Python code examples."
        }
      }
    },
    "suffix": {
      "description": "默认为null 在插入文本的补全之后出现的后缀。",
      "type": "string",
      "x-i18n": {
        "en-US": {
          "description": "Defaults to null The suffix that appears after completion of inserted text."
        }
      }
    },
    "temperature": {
      "description": "默认为1 要使用的采样温度,介于0和2之间。更高的值(如0.8)将使输出更随机,而更低的值(如0.2)将使其更集中和确定。  我们通常建议更改这个或top_p,而不是两者都更改。",
      "title": "",
      "type": "integer",
      "x-i18n": {
        "en-US": {
          "description": "Defaults to 1 The 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.  We generally recommend changing this or top_p, not both."
        }
      }
    },
    "top_p": {
      "description": "表示最终用户的唯一标识符,这可以帮助OpenAI监控和检测滥用。 了解更多。",
      "type": "integer",
      "x-i18n": {
        "en-US": {
          "description": "Represents a unique identifier for the end user, which can help OpenAI monitor and detect abuse. learn more."
        }
      }
    },
    "user": {
      "type": "string"
    }
  },
  "required": [
    "model",
    "prompt",
    "user"
  ]
}

请求示例 · 示例 1#

{
  "max_tokens": 30,
  "model": "gpt-3.5-turbo-instruct",
  "prompt": "你好,",
  "temperature": 0
}

响应示例 · 成功示例#

{
  "choices": [
    {
      "finish_reason": "length",
      "index": 0,
      "logprobs": null,
      "text": "我是小冰,很高兴认识你。我是一个人工智能助手,可以回"
    }
  ],
  "created": 1753859563,
  "id": "cmpl-ByvHP6AWeB1L5vWZSPNHsB12sU9db",
  "model": "gpt-3.5-turbo-instruct",
  "object": "text_completion",
  "usage": {
    "completion_tokens": 30,
    "prompt_tokens": 3,
    "total_tokens": 33
  }
}

请求参数

Authorization
Bearer Token
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
or
Header 参数

Body 参数application/json

示例
{
    "model": "gpt-3.5-turbo-instruct",
    "prompt": "你好,",
    "max_tokens": 30,
    "temperature": 0,
    "user": "default-user"
}

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
cURL
curl --location '/v1/completions' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
    "model": "gpt-3.5-turbo-instruct",
    "prompt": "你好,",
    "max_tokens": 30,
    "temperature": 0,
    "user": "default-user"
}'

返回响应

🟢200Ok
application/json
Bodyapplication/json

示例
{
    "id": "cmpl-ByvHP6AWeB1L5vWZSPNHsB12sU9db",
    "object": "text_completion",
    "created": 1753859563,
    "model": "gpt-3.5-turbo-instruct",
    "system_fingerprint": "fp_abc123",
    "choices": [
        {
            "index": 0,
            "finish_reason": "length",
            "text": "我是小冰,很高兴认识你。我是一个人工智能助手,可以回",
            "logprobs": ""
        }
    ],
    "usage": {
        "prompt_tokens": 3,
        "completion_tokens": 30,
        "total_tokens": 33
    }
}
🟠400请求有误
🟠401没有权限
修改于 2026-10-24 18:33:00
上一页
获取令牌支持模型
下一页
创建函数调用
Built with