Skip to content

onedotnet/soxai-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SoxAI — Go SDK

Go Reference

The official Go client for SoxAI — a unified AI API gateway giving you access to 200+ AI models from 40+ providers through a single OpenAI-compatible API.

Installation

go get github.com/onedotnet/soxai-go

Quick Start

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/onedotnet/soxai-go"
	"github.com/openai/openai-go"
)

func main() {
	client := soxai.NewClient(os.Getenv("SOXAI_API_KEY"))

	resp, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
		Model: "claude-sonnet-4-6", // or gpt-4o, gemini-2.5-flash, deepseek-chat, ...
		Messages: []openai.ChatCompletionMessageParamUnion{
			openai.UserMessage("Hello!"),
		},
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(resp.Choices[0].Message.Content)
}

Why SoxAI?

  • One API key for OpenAI, Anthropic, Google, DeepSeek, Meta, and 35+ more providers
  • Automatic failover — if one provider goes down, requests route to another
  • Team management — per-developer API keys with spending limits
  • OpenAI Go SDK compatible — returns openai.Client so all methods work as-is
  • Free $5 credit to start, no credit card required

Examples

Streaming

stream := client.Chat.Completions.NewStreaming(ctx, openai.ChatCompletionNewParams{
	Model: "gpt-4o-mini",
	Messages: []openai.ChatCompletionMessageParamUnion{
		openai.UserMessage("Write a haiku about APIs."),
	},
})
defer stream.Close()

for stream.Next() {
	chunk := stream.Current()
	if len(chunk.Choices) > 0 {
		fmt.Print(chunk.Choices[0].Delta.Content)
	}
}

Custom Options

import (
	"net/http"
	"time"
	"github.com/openai/openai-go/option"
)

client := soxai.NewClient(
	os.Getenv("SOXAI_API_KEY"),
	option.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
)

Links

License

MIT

About

SoxAI Go SDK — Access 200+ AI models through one OpenAI-compatible API

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages