Skip to content

Your first API call

Get a key, list the models your server offers, and send a chat request with any OpenAI client.

1. Get a key

In the Fadenstack chat or console, open your profile (your avatar at the top right, then Manage Profile) and create a token under API token. Give it a name that says where you will use it, and pick a lifetime: an hour, a day, a week, 30 or 90 days, or a year. Copy the token; it is shown once.

On a server newer than 0.4.1, the same card lists your tokens. Revoke one you no longer need, or one that may have leaked: the server refuses it within a minute.

If you have no account on the server, ask your administrator for one.

Treat the key like a password

The key acts as you, with your access to the server's models and tools. Keep it in an environment variable or a secret store, never in code, and give it the shortest lifetime that works.

2. Find your server's address

The API is at /v1 on your Fadenstack server, for example https://ai.example.internal/v1. The examples below read it, and the key, from the environment:

export FADEN_BASE_URL=https://ai.example.internal/v1
export FADEN_API_KEY=<your token>

3. List the models

curl -s "$FADEN_BASE_URL/models" -H "Authorization: Bearer $FADEN_API_KEY"

Each entry's id is a model name you can use, chosen by your administrator, for example team-assistant. Its kind says whether it is a chat, embeddings or scoring model. See Models.

4. Send a chat request

curl -s "$FADEN_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $FADEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "team-assistant",
    "messages": [{"role": "user", "content": "Summarise the benefits of a shared AI system in two sentences."}]
  }'
import os
from openai import OpenAI

client = OpenAI(base_url=os.environ["FADEN_BASE_URL"], api_key=os.environ["FADEN_API_KEY"])

reply = client.chat.completions.create(
    model="team-assistant",
    messages=[{"role": "user", "content": "Summarise the benefits of a shared AI system in two sentences."}],
)
print(reply.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({ baseURL: process.env.FADEN_BASE_URL, apiKey: process.env.FADEN_API_KEY });

const reply = await client.chat.completions.create({
  model: "team-assistant",
  messages: [{ role: "user", content: "Summarise the benefits of a shared AI system in two sentences." }],
});
console.log(reply.choices[0].message.content);
using System.ClientModel;
using OpenAI;
using OpenAI.Chat;

var client = new ChatClient(
    model: "team-assistant",
    credential: new ApiKeyCredential(Environment.GetEnvironmentVariable("FADEN_API_KEY")!),
    options: new OpenAIClientOptions { Endpoint = new Uri(Environment.GetEnvironmentVariable("FADEN_BASE_URL")!) });

ChatCompletion reply = client.CompleteChat("Summarise the benefits of a shared AI system in two sentences.");
Console.WriteLine(reply.Content[0].Text);

Streaming works as with OpenAI: set "stream": true and read the server-sent events.

If the certificate is not trusted

Many Fadenstack servers use their own certificate authority. Get the CA certificate from your administrator and let your client trust it, instead of turning certificate checks off:

  • curl: --cacert ca.crt
  • Python: export SSL_CERT_FILE=ca.crt, or pass http_client=httpx.Client(verify="ca.crt") to OpenAI
  • Node: export NODE_EXTRA_CA_CERTS=ca.crt
  • .NET on Windows: install the CA in the Windows certificate store

Next

  • Chat completions: what the server adds to the OpenAI API, such as skills and tool modes.
  • Your first agent: an assistant inside your own software, with the SDKs.