Getting started¶
1. Install¶
Go 1.21 or newer. There are no other dependencies.
2. Get a key¶
- Sign up at freetheai.org.
- Open API keys and create a key. It starts with
ftai_and is shown once, so copy all of it. - 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.
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.