Crea un completamento di testo
POST/v1/complete
Deprecated: Use the Messages API instead.
[Legacy] Crea un completamento di testo.
L'API Text Completions è un'API legacy. Consigliamo di utilizzare l'API Messages d'ora in avanti.
I modelli e le funzionalità futuri non saranno compatibili con Text Completions. Consulta la nostra guida alla migrazione per indicazioni su come migrare da Text Completions a Messages.
Parameters
Returns
Crea un completamento di testo
package main
import (
"context"
"fmt"
"github.com/anthropics/anthropic-sdk-go"
"github.com/anthropics/anthropic-sdk-go/option"
)
func main() {
client := anthropic.NewClient(
option.WithAPIKey("my-anthropic-api-key"),
)
completion, err := client.Completions.New(context.TODO(), anthropic.CompletionNewParams{
MaxTokensToSample: 256,
Model: anthropic.ModelClaudeHaiku5_5,
Prompt: "\n\nHuman: Hello, world!\n\nAssistant:",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", 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"
}