soxai

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 2 Imported by: 0

README

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}),
)

License

MIT

Documentation

Overview

Package soxai provides a Go client for the SoxAI unified AI API gateway.

SoxAI gives you access to 200+ AI models from 40+ providers (OpenAI, Anthropic, Google, DeepSeek, etc.) through one OpenAI-compatible API.

Example:

client := soxai.NewClient(os.Getenv("SOXAI_API_KEY"))
resp, err := client.Chat.Completions.New(ctx, openai.ChatCompletionNewParams{
    Model: "claude-sonnet-4-6",
    Messages: []openai.ChatCompletionMessageParamUnion{
        openai.UserMessage("Hello!"),
    },
})

Get your API key: https://console.soxai.io/register (free $5 credit) Model list: https://www.soxai.io/models Documentation: https://www.soxai.io/docs

Index

Constants

View Source
const BaseURL = "https://api.soxai.io/v1"

BaseURL is the default SoxAI gateway endpoint.

View Source
const Version = "0.1.0"

Version is the current version of the soxai-go package.

Variables

This section is empty.

Functions

func NewClient

func NewClient(apiKey string, opts ...option.RequestOption) openai.Client

NewClient returns an openai.Client pre-configured for the SoxAI gateway.

All OpenAI Go SDK features work exactly the same — requests route through SoxAI to 200+ models. Pass additional option.RequestOption values to override defaults (e.g. custom HTTP client, timeouts, headers).

If apiKey is empty, the client will fall back to the OPENAI_API_KEY environment variable (consistent with the underlying openai-go behavior).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL