One Go interface for chat, streaming, tool calls, structured output, embeddings, images and decisions across AI providers. Republic stops at providers: agent loops, tool execution and gateways stay in your application.
Requires Go 1.23 or later.
go get github.com/AstraFoundry/republic
export REPUBLIC_OPENAI_API_KEY="your-api-key"package main
import (
"context"
"fmt"
"log"
"github.com/AstraFoundry/republic"
)
func main() {
model, err := republic.GetModel("openai:gpt-6-sol", republic.ProviderConfig{})
if err != nil { log.Fatal(err) }
defer model.Close()
response, err := model.Chat(context.Background(), "Explain a tool call.", nil)
if err != nil { log.Fatal(err) }
fmt.Println(response.Text())
stream, err := model.Stream(context.Background(), "Explain streaming.", nil)
if err != nil { log.Fatal(err) }
defer stream.Close()
for event, err := range stream.Events() {
if err != nil { log.Print(err); return }
if event.Type == "text_delta" { fmt.Print(event.Chunk) }
}
}Model names use provider:model. Credentials default to
REPUBLIC_<PROVIDER>_API_KEY; hyphens become underscores. Codex, GitHub Copilot
and Grok can reuse their CLI credentials. Every request accepts a context for
cancellation and deadlines.
- Quickstart
- Providers and supported formats
- Authentication
- Tools and structured output
- Configuration and API reference
- Migration and compatibility
make check
make test
make parity
make buildThe library, tests and compatibility checks require only Go. The original
Python implementation and its tooling have been removed. make parity compares
570 request cases and 58 recorded responses against frozen original-behavior
baselines in testdata; it does not run a second implementation. See
Contributing for development and optional documentation tools.