Eine Text Completion erstellen
POST/v1/complete
Deprecated: Use the Messages API instead.
[Veraltet] Eine Text Completion erstellen.
Die Text Completions API ist eine veraltete API. Wir empfehlen, künftig die Messages API zu verwenden.
Zukünftige Modelle und Funktionen werden nicht mit Text Completions kompatibel sein. In unserem Migrationsleitfaden findest du Hinweise zur Migration von Text Completions zu Messages.
Parameters
Returns
Eine Text Completion erstellen
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"
}