import requests
response = requests.post(
"https://inference.phala.com/v1/chat/completions",
headers={
"Authorization": "Bearer <API_KEY>",
"Content-Type": "application/json",
},
json={
"model": "z-ai/glm-5.3",
"messages": [
{"role": "user", "content": "What is the weather like in Los Angeles?"},
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "weather",
"strict": True,
"schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City or location name",
},
"temperature": {
"type": "number",
"description": "Temperature in Celsius",
},
"conditions": {
"type": "string",
"description": "Weather conditions description",
},
},
"required": ["location", "temperature", "conditions"],
"additionalProperties": False,
},
},
},
},
)
data = response.json()
info = data["choices"][0]["message"]["content"]
print(info)