ohmygpt-logoOhMyGPT Cookbook
OpenAPI/V1

Completion (Legacy)

这里仅给出示例,完整文档请查看官方文档:https://platform.openai.com/docs/api-reference/completions

POST
/v1/completions

Authorization

AuthorizationRequiredBearer <token>

In: header

Request Body

application/x-www-form-urlencodedOptional
modelstring

模型名称

promptstring

Prompt

max_tokensstring

最大生成Tokens长度

streamstring

是否流式返回

Response Body

TypeScript Definitions

Use the response body type in TypeScript.

curl -X POST "https://api.ohmygpt.com/v1/completions" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d 'model=gpt-3.5-turbo-instruct&prompt=Say+this+is+a+test.&max_tokens=100&stream=false'

{
  "id": "cmpl-8Jdl0foXbnLIAObJnB0GSKUvAri0X",
  "object": "text_completion",
  "created": 1699691750,
  "model": "gpt-3.5-turbo-instruct",
  "choices": [
    {
      "text": "\n\nThis is a test.",
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 6,
    "completion_tokens": 6,
    "total_tokens": 12
  }
}