TypnoAI
English Inloggen
API in OpenAI-stijl

API in OpenAI-stijl

Basisadres: https://dev.typno.ai/v1. Meld je aan met Authorization: Bearer tpk-....

Chat completions

POST /v1/chat/completions neemt dezelfde body als OpenAI: model, messages, en naar keuze stream, max_tokens, temperature, top_p, stop, tools, tool_choice en response_format.

curl https://dev.typno.ai/v1/chat/completions \
  -H "Authorization: Bearer $TYPNO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mistral4-119b",
    "messages": [
      {"role": "system", "content": "You answer briefly."},
      {"role": "user", "content": "What is the capital of the Netherlands?"}
    ]
  }'

Streaming

Zet "stream": true voor server-sent events met het antwoord terwijl het geschreven wordt. Voeg "stream_options": {"include_usage": true} toe voor een laatste blok met het tokenverbruik.

stream = client.chat.completions.create(
    model="mistral4-119b",
    messages=[{"role": "user", "content": "Write a haiku about rain."}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

Tools

Geef functies mee in tools; het model antwoordt met tool_calls, jij voert ze uit en stuurt de uitkomsten terug als berichten met role: "tool".

{
  "model": "glm5.3-754b",
  "messages": [{"role": "user", "content": "What is the weather in Utrecht?"}],
  "tools": [{
    "type": "function",
    "function": {
      "name": "get_weather",
      "description": "Current weather for a city",
      "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}
    }
  }]
}

Afbeeldingen in een bericht

Modellen met beeld nemen afbeeldingen als image_url-delen, als openbaar adres of als data:-URL.

{"role": "user", "content": [
  {"type": "text", "text": "What is in this picture?"},
  {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}}
]}

Niet inbegrepen

De API zoekt niet op het web en neemt geen bestanden aan; dat kan alleen in de chat. Embeddings, audio en fine-tuning worden niet aangeboden.