Chat & Text

Basic Chat Completion

Send a single-turn message to any supported LLM and print the response.

Python

python
import requests

BASE_URL = "https://api.oneinfer.ai"

# Authenticate
token = requests.post(
    f"{BASE_URL}/v1/ula/oauth-authentication?api_key=YOUR_API_KEY"
).json()["access_token"]

headers = {
    "Authorization": f"Bearer {token}",
    "Content-Type": "application/json",
}

response = requests.post(
    f"{BASE_URL}/v1/ula/chat/completions",
    headers=headers,
    json={
        "provider": "openai",
        "model": "gpt-4o-mini",
        "messages": [{"role": "user", "content": "What is AI inference?"}],
        "max_tokens": 256,
        "temperature": 0.7,
    },
)

print(response.json()["data"]["text"])

cURL

bash
curl -X POST "https://api.oneinfer.ai/v1/ula/chat/completions" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "openai",
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "What is AI inference?"}],
    "max_tokens": 256
  }'