Responses
Text Generation
HasteKit SDK supports generating text content with various LLM providers like OpenAI, Anthropic, and Gemini.
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
resp, err := model.NewResponses(ctx, &responses.Request{
Instructions: utils.Ptr("You are a helpful assistant."),
Input: responses.InputUnion{
OfString: utils.Ptr("What is the capital of France?"),
},
})
// Access the text output
for _, output := range resp.Output {
if output.OfOutputMessage != nil {
for _, content := range output.OfOutputMessage.Content {
if content.OfOutputText != nil {
fmt.Println(content.OfOutputText.Text)
}
}
}
}
import (
"context"
"fmt"
"github.com/hastekit/agent-sdk-go/pkg/gateway/llm/responses"
"github.com/hastekit/agent-sdk-go/pkg/utils"
)
func main() {
// ... client and model initialization ...
stream, err := model.NewStreamingResponses(context.Background(), &responses.Request{
Input: responses.InputUnion{
OfString: utils.Ptr("Write a poem about coding."),
},
})
if err != nil {
panic(err)
}
for chunk := range stream {
// Handle different types of chunks
if chunk.OfOutputTextDelta != nil {
fmt.Print(chunk.OfOutputTextDelta.Delta)
}
}
}
resp, err := model.NewResponses(ctx, &responses.Request{
Input: responses.InputUnion{
OfInputMessageList: responses.InputMessageList{
{
OfEasyInput: &responses.EasyMessage{
Role: "user",
Content: responses.EasyInputContentUnion{OfString: utils.Ptr("Hi!")},
},
},
{
OfEasyInput: &responses.EasyMessage{
Role: "assistant",
Content: responses.EasyInputContentUnion{OfString: utils.Ptr("Hello! How can I help you?")},
},
},
{
OfEasyInput: &responses.EasyMessage{
Role: "user",
Content: responses.EasyInputContentUnion{OfString: utils.Ptr("Tell me a joke.")},
},
},
},
},
})