POST /v1/responses
Tools are declared with a flat function schema (no nested function key). The model returns function_call items inside the output array.
tools = [{
"type": "function",
"name": "get_weather",
"description": "Get the weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
}]
Full loop
from openai import OpenAI
import json
client = OpenAI(base_url="https://api.abliteration.ai/v1", api_key=os.environ["ABLIT_KEY"])
resp = client.responses.create(
model="abliterated-model",
input="What's the weather in Lagos?",
tools=tools,
)
next_input = []
for item in resp.output:
if item.type == "function_call":
args = json.loads(item.arguments)
result = get_weather(args["city"]) # your function
next_input.append({
"type": "function_call_output",
"call_id": item.call_id,
"output": json.dumps(result),
})
final = client.responses.create(
model="abliterated-model",
input=next_input,
previous_response_id=resp.id,
tools=tools,
)
print(final.output_text)
Streaming
Stream with stream=True. Tool arguments arrive as response.function_call.arguments.delta events; a response.function_call.done event signals the call is complete.
tool_choice={"type": "function", "name": "get_weather"}
Multiple function_call items can appear in a single output array. Produce one function_call_output per call_id.Last modified on April 21, 2026