import json
import httpx
from openai import OpenAI
# Replace the entire value with your actual key before running.
API_KEY = "sk-your-api-key"
# Use the exact name from Model Square. This example uses gpt-5.4-mini.
MODEL = "gpt-5.4-mini"
client = OpenAI(
api_key=API_KEY,
base_url="https://moxus.ai/v1",
# Connect directly to Moxus AI without reading system or terminal proxy variables.
http_client=httpx.Client(trust_env=False, timeout=60.0),
)
response = client.chat.completions.create(
model=MODEL,
messages=[
{"role": "user", "content": "Alice is 28 and works as an engineer."}
],
response_format={
"type": "json_schema",
"json_schema": {
"name": "person_info",
"strict": True,
"schema": {
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "integer"},
"job": {"type": "string"},
},
"required": ["name", "age", "job"],
"additionalProperties": False,
},
},
},
)
data = json.loads(response.choices[0].message.content)
print(data["name"], data["age"], data["job"])