Documentation / guides
Overview
Select a wire dialect and keep model identity separate from provider policy.
model.APIFormat names a wire dialect. It is intentionally an open string:
unknown values are valid in the model package when a caller supplies matching
codec and router implementations.
Labels
type APIFormat string
const (
APIFormatOpenAI APIFormat = "openai"
APIFormatOpenAIResponses APIFormat = "openai-responses"
APIFormatAnthropic APIFormat = "anthropic"
APIFormatGemini APIFormat = "gemini"
APIFormatBedrockConverse APIFormat = "bedrock-converse"
)
The label does not carry credentials, endpoint defaults, or provider policy.
Model.Validate checks structural safety, while composition code binds the
label to a codec, router, and credential source.
Routing
| Format | Route helper | Invoke | Stream |
|---|---|---|---|
| OpenAI Chat | route.StaticChat("/chat/completions") | same path | same path, body flag |
| OpenAI Responses | route.StaticChat("/responses") | same path | same path, body flag |
| Anthropic | route.StaticChat("/messages") | same path | same path, body flag |
| Gemini | route.GeminiGenerateContent() | :generateContent | :streamGenerateContent?alt=sse |
| Bedrock Converse | caller-supplied route | same body | route/API operation chooses stream |
Source and proof
Run go test ./model ./route.