Skip to content

Getting started

1. Install

go get github.com/Free-The-Ai/freetheai-go@latest

Go 1.21 or newer. There are no other dependencies.

2. Get a key

  1. Sign up at freetheai.org.
  2. Open API keys and create a key. It starts with ftai_ and is shown once, so copy all of it.
  3. Free models need the daily check-in, one quick captcha a day.

The free tier is 50 requests a day, reset at 00:00 UTC. The plan page shows how to raise it.

export FREETHEAI_API_KEY="ftai_..."
$env:FREETHEAI_API_KEY = "ftai_..."

3. Pick a model

Model IDs look like fta/<provider>/<model>. Browse them on freetheai.org/models or list them in code:

models, err := client.Models.List(ctx)
if err != nil {
    log.Fatal(err)
}
for _, model := range models {
    fmt.Println(model.ID)
}

4. Send a request

reply, err := client.Chat.Completions.New(ctx, freetheai.ChatCompletionParams{
    Model: "fta/zai/glm-5.3",
    Messages: []freetheai.Message{
        {Role: "system", Content: "You are a concise assistant."},
        {Role: "user", Content: "What is an API gateway?"},
    },
})
if err != nil {
    log.Fatal(err)
}
fmt.Println(reply.Choices[0].Message.Content)
fmt.Println(reply.Usage.TotalTokens)

Pass a context.Context to every call so you can cancel it or set a deadline.