Skip to content
AstraFoundryPublic
forked from bubbuild/republic

About

Go library for AI providers.

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

134 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Republic

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.

Documentation

Development

make check
make test
make parity
make build

The 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.

License

Apache 2.0.

About

Go library for AI providers.

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages