Text Completion 생성
POST/v1/complete
Deprecated: Use the Messages API instead.
[레거시] Text Completion을 생성합니다.
Text Completions API는 레거시 API입니다. 앞으로는 Messages API를 사용하는 것을 권장합니다.
향후 모델 및 기능은 Text Completions와 호환되지 않습니다. Text Completions에서 Messages로 마이그레이션하는 방법은 마이그레이션 가이드를 참조하세요.
Parameters
Returns
Text Completion 생성
package com.anthropic.example;
import com.anthropic.client.AnthropicClient;
import com.anthropic.client.okhttp.AnthropicOkHttpClient;
import com.anthropic.models.completions.Completion;
import com.anthropic.models.completions.CompletionCreateParams;
import com.anthropic.models.messages.Model;
public final class Main {
private Main() {}
public static void main(String[] args) {
AnthropicClient client = AnthropicOkHttpClient.fromEnv();
CompletionCreateParams params = CompletionCreateParams.builder()
.maxTokensToSample(256L)
.model(Model.CLAUDE_HAIKU_5_5)
.prompt("\n\nHuman: Hello, world!\n\nAssistant:")
.build();
Completion completion = client.completions().create(params);
}
}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"
}