Basic Chat Completion
Send a conversation history and receive an AI-generated response.curl --request POST \
--url https://geoff.ai/api/v1/text/chat \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "magma",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing in simple terms."}
],
"max_tokens": 1024
}'
import requests
response = requests.post(
"https://geoff.ai/api/v1/text/chat",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "magma",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing in simple terms."},
],
"max_tokens": 1024,
},
)
print(response.json())
const response = await fetch("https://geoff.ai/api/v1/text/chat", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "magma",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Explain quantum computing in simple terms." },
],
max_tokens: 1024,
}),
});
const data = await response.json();
console.log(data);
Multi-turn Conversation
Maintain conversation context by passing the full message history:messages = [
{"role": "system", "content": "You are a helpful coding assistant."},
{"role": "user", "content": "Write a Python function to reverse a string."},
]
# First response
response = requests.post(url, headers=headers, json={"model": model, "messages": messages})
assistant_message = response.json()["choices"][0]["message"]
# Continue the conversation
messages.append(assistant_message)
messages.append({"role": "user", "content": "Now make it handle Unicode correctly."})
response = requests.post(url, headers=headers, json={"model": model, "messages": messages})