Создать текстовое завершение
POST/v1/complete
Deprecated: Use the Messages API instead.
[Устаревшее] Создание текстового завершения.
Text Completions API — устаревший API. В дальнейшем мы рекомендуем использовать Messages API.
Будущие модели и функции не будут совместимы с Text Completions. Рекомендации по переходу с Text Completions на Messages см. в нашем руководстве по миграции.
Parameters
Returns
Создать текстовое завершение
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env["ANTHROPIC_API_KEY"] // This is the default and can be omitted
});
const completion = await client.completions.create({
max_tokens_to_sample: 256,
model: "claude-2.1",
prompt: "\n\nHuman: Hello, world!\n\nAssistant:"
});
console.log(completion.id);Response 200
{
"id": "compl_018CKm6gsux7P8yMcwZbeCPw",
"completion": " Hello! My name is Claude.",
"model": "claude-2.1",
"stop_reason": "stop_sequence",
"type": "completion"
}Returns Examples
Response 200
{
"id": "compl_018CKm6gsux7P8yMcwZbeCPw",
"completion": " Hello! My name is Claude.",
"model": "claude-2.1",
"stop_reason": "stop_sequence",
"type": "completion"
}