API Quickstart

Get your first API call running in 5 minutes.

Prerequisites

  • Thox.ai device powered on and connected to your network
  • Device showing green LED (ready state)
  • Computer on the same network as the device
1

Verify Connection

First, verify that your device is accessible on the network:

# Check if device is reachable

curl http://thox.local:8080/health

# Expected response:

{"status": "healthy", "version": "1.2.0"}

If thox.local doesn't resolve, use your device's IP address instead (check your router's DHCP client list).

2

List Available Models

See what models are available on your device:

curl http://thox.local:8080/v1/models

# Response:

{
  "data": [
    {
      "id": "thox-coder",
      "object": "model",
      "owned_by": "thoxai"
    },
    {
      "id": "thox-chat",
      "object": "model",
      "owned_by": "thoxai"
    }
  ]
}
3

Make Your First Request

Using cURL

curl http://thox.local:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "thox-coder",
    "messages": [
      {"role": "user", "content": "Write a hello world in Python"}
    ]
  }'

Using Python

import requests

response = requests.post(
    "http://thox.local:8080/v1/chat/completions",
    json={
        "model": "thox-coder",
        "messages": [
            {"role": "user", "content": "Write a hello world in Python"}
        ]
    }
)

print(response.json()["choices"][0]["message"]["content"])

Using JavaScript/Node.js

const response = await fetch('http://thox.local:8080/v1/chat/completions', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    model: 'thox-coder',
    messages: [
      { role: 'user', content: 'Write a hello world in Python' }
    ]
  })
});

const data = await response.json();
console.log(data.choices[0].message.content);
4

Enable Streaming

For real-time token-by-token output, enable streaming:

import requests

response = requests.post(
    "http://thox.local:8080/v1/chat/completions",
    json={
        "model": "thox-coder",
        "messages": [
            {"role": "user", "content": "Explain async/await"}
        ],
        "stream": True
    },
    stream=True
)

for line in response.iter_lines():
    if line:
        print(line.decode())

Next Steps