简介

概述

OpenAI 的 API 可用于几乎所有需要理解自然语言的任务,也包括生成自然语言、代码和图像。我们提供了一些列适合不同任务的、具有不同能力水平的模型,以及能够为你自定义模型进行微调的功能。这些模型可用于从内容生成到语义搜索及分类的一切任务。

基础概念

我们建议你完成我们的快速入门教程,通过实践、互动的例子去熟悉相关的基础概念。

快速入门教程
通过构建一个快速示例应用程序来学习
提示指令 Prompts

设计你的提示指令本质上就是你如何对模型进行“编程”,通常是通过提供一些指令或几个示例来完成的。这与大多数其他 NLP 服务不同,它们那些服务是为单一任务设计的,如情感分类命名实体识别。与之相反,我们的文本补全功能以及聊天补全终端几乎可用于任何任务,包括内容或代码生成、摘要、扩展、对话、创意写作、风格转移等等。

标记 Tokens

我们的模型在理解和处理文本时,会将其分解为一个个标记。这些标记可能是一个单词,也可能仅仅只是字符块。例如,“hamburger”这个词会被分解为“ham”,“bur”和“ger”三个标记,而像“pear”这样的短小常用词则被视为一个标记。许多标记会以空格开始,比如“ hello”和“ bye”。

对于一次 API 请求而言,你问题输入的标记加上结果返回的标记数就是这次请求所处理的标记数量。按经验粗略估算,对于英文文本而言,一个标记大约是 4 个字符或 0.75 个单词。 One limitation to keep in mind is that your text prompt and generated completion combined must be no more than the model's maximum context length (for most models this is 2048 tokens, or about 1500 words). Check out our tokenizer tool to learn more about how text translates to tokens.

Models

The API is powered by a set of models with different capabilities and price points. GPT-4 is our latest and most powerful model. GPT-3.5-Turbo is the model that powers ChatGPT and is optimized for conversational formats. To learn more about these models and what else we offer, visit our models documentation.

Next steps

  • Keep our usage policies in mind as you start building your application.
  • Explore our examples library for inspiration.
  • Jump into one of our guides to start building.
Guides
Chat Beta
Learn how to use chat-based language models
Text completion
Learn how to generate or edit text
Embeddings
Learn how to search, classify, and compare text
Speech to text Beta
Learn how to turn audio into text
Image generation Beta
Learn how to generate or edit images
Fine-tuning
Learn how to train a model for your use case
12