Examples
Working snippets in four languages. Replace YOUR_API_TOKEN with the token from Getting started.
Each snippet below sends the same prompt to POST /api/ai and prints the assistant text. They are intentionally minimal: no SDK, no clever wrappers, just the standard library or a single well-known HTTP client per language.
curl
Shell
curl https://scouq.com/api/ai \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "llama-3.3-70b-versatile",
"messages": [
{ "role": "user", "content": "ARV 240000, rehab 28000, asking 145000. Quick take on the 70 percent rule?" }
],
"max_tokens": 250,
"temperature": 0.3
}' | jq -r '.choices[0].message.content'
Python
Standard library only. Works on Python 3.8+.
Python
import json
import os
import urllib.request
TOKEN = os.environ["SCOUQ_API_TOKEN"]
body = {
"model": "llama-3.3-70b-versatile",
"messages": [
{"role": "user", "content": "ARV 240000, rehab 28000, asking 145000. Quick take on the 70 percent rule?"}
],
"max_tokens": 250,
"temperature": 0.3,
}
req = urllib.request.Request(
"https://scouq.com/api/ai",
data=json.dumps(body).encode("utf-8"),
headers={
"Authorization": "Bearer " + TOKEN,
"Content-Type": "application/json",
},
method="POST",
)
with urllib.request.urlopen(req, timeout=30) as resp:
data = json.loads(resp.read())
print(data["choices"][0]["message"]["content"])
With requests:
Python (requests)
import os
import requests
r = requests.post(
"https://scouq.com/api/ai",
headers={"Authorization": "Bearer " + os.environ["SCOUQ_API_TOKEN"]},
json={
"model": "llama-3.3-70b-versatile",
"messages": [
{"role": "user", "content": "ARV 240000, rehab 28000, asking 145000. Quick take?"}
],
"max_tokens": 250,
"temperature": 0.3,
},
timeout=30,
)
r.raise_for_status()
print(r.json()["choices"][0]["message"]["content"])
Rust
Uses reqwest with the blocking feature and serde_json. Add to Cargo.toml:
Cargo.toml
[dependencies]
reqwest = { version = "0.12", features = ["blocking", "json"] }
serde_json = "1"
Rust
use serde_json::{json, Value};
use std::env;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = env::var("SCOUQ_API_TOKEN")?;
let body = json!({
"model": "llama-3.3-70b-versatile",
"messages": [
{ "role": "user", "content": "ARV 240000, rehab 28000, asking 145000. Quick take?" }
],
"max_tokens": 250,
"temperature": 0.3
});
let client = reqwest::blocking::Client::new();
let resp: Value = client
.post("https://scouq.com/api/ai")
.bearer_auth(token)
.json(&body)
.send()?
.error_for_status()?
.json()?;
let text = resp["choices"][0]["message"]["content"]
.as_str()
.unwrap_or("");
println!("{}", text);
Ok(())
}
Node
Node 18+ has fetch built in. No dependencies needed.
Node (JavaScript)
const token = process.env.SCOUQ_API_TOKEN;
async function main() {
const resp = await fetch("https://scouq.com/api/ai", {
method: "POST",
headers: {
"Authorization": "Bearer " + token,
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "llama-3.3-70b-versatile",
messages: [
{ role: "user", content: "ARV 240000, rehab 28000, asking 145000. Quick take?" }
],
max_tokens: 250,
temperature: 0.3
})
});
if (!resp.ok) {
const err = await resp.text();
throw new Error("HTTP " + resp.status + ": " + err);
}
const data = await resp.json();
console.log(data.choices[0].message.content);
}
main().catch(function (e) { console.error(e); process.exit(1); });
Handling rate limits
Add a one-shot retry on 429 with Retry-After. This pattern works in every language; the Python version below is representative.
Python
import time
import requests
def call_with_retry(token, body, max_retries=2):
url = "https://scouq.com/api/ai"
headers = {"Authorization": "Bearer " + token}
for attempt in range(max_retries + 1):
r = requests.post(url, headers=headers, json=body, timeout=30)
if r.status_code != 429:
r.raise_for_status()
return r.json()
wait = int(r.headers.get("Retry-After", "30"))
time.sleep(wait)
r.raise_for_status()