Add images, audio, and model thinking
You declare images, files, audio, and other media in the program contract. Provider support determines which media and thinking controls are available.
Worked example
See the idea in context
// Realtime audio over WebSocket — needs Go 1.23+
client := ax.NewOpenAIResponsesClient(map[string]ax.Value{"model": "gpt-realtime-2", "api_key": os.Getenv("OPENAI_APIKEY")})
request := map[string]ax.Value{"model": "gpt-realtime-2", "chat_prompt": ax.Array(ax.Object("role", "user", "content", "Say hello.")), "audio": ax.Object("output", ax.Object("voice", "alloy"))}
final, _ := client.RealtimeChat(context.Background(), request, nil, nil) // one merged turn: transcript + base64 PCM audio
// Realtime models also route transparently through Chat(); Chat() accepts input_audio parts; Transcribe()/Speak() do batch STT/TTS.Run itIn your own project
go get github.com/ax-llm/ax/packages/go
package main
import (
"context"
"fmt"
"os"
axllm "github.com/ax-llm/ax/packages/go"
)
func main() {
client := axllm.NewAI("openai", map[string]axllm.Value{"apiKey": os.Getenv("OPENAI_API_KEY")})
classify := axllm.NewAx("review:string -> sentiment:class \"positive, negative, neutral\"", nil)
result, err := classify.Forward(context.Background(), client, map[string]axllm.Value{
"review": "Useful and boring in the best way."
}, nil)
if err != nil {
panic(err)
}
fmt.Println("sentiment:", result.(map[string]axllm.Value)["sentiment"])
}Set OPENAI_APIKEY in your environment before running provider-backed code.
From a clone of the ax repo:
npm run example -- go src/examples/go/long-agents/smart_defaults_agent.goActive practice
Answer 2 in a row to learn this · attempt 1