OpenAI Agents SDK
Run an existing agent through the explicit Chat Completions model adapter.
The Agents SDK commonly defaults to the Responses API. Internalize supports Chat Completions, so select OpenAIChatCompletionsModel explicitly.
pip install openai-agentsimport asyncio
import os
from openai import AsyncOpenAI
from agents import Agent, Runner, OpenAIChatCompletionsModel, set_tracing_disabled
# Configure a separate tracing destination if your application needs one.
set_tracing_disabled(True)
client = AsyncOpenAI(
base_url="https://convergingthought.com/v1",
api_key=os.environ["INTERNALIZE_API_KEY"],
max_retries=0,
)
agent = Agent(
name="Assistant",
model=OpenAIChatCompletionsModel(model="glm-5.3", openai_client=client),
)
async def main():
result = await Runner.run(agent, "Hello!")
print(result.final_output)
asyncio.run(main())Learned weights
Construct a client for an authorized subject with default_headers={"X-Internalize-Subject": subject_id}. The API key still selects the project. The header selects the learning identity inside that project, and must come from trusted application state.
An agent's instructions, current task, tools, and conversation history remain ordinary context. Internalized source material does not need to be pasted into that history after successful activation.
Function tools
Use ordinary function tools with strict_mode=False; strict constrained schemas are not supported by this endpoint. Validate arguments in the handler. The model may ask to execute a function, but your runtime retains responsibility for authorization and execution.
For internalize, take only content from the model and bind the subject on your server. Prefer a durable handler that records the API job ID and checks activation. If the operation outlives a runner invocation, resume that same job rather than recreate it.
Compatibility limits
Responses API, hosted OpenAI tools, voice, images, and JSON-schema constrained decoding are not provided. Streaming uses buffered SSE, so an agent can consume the expected stream shape but does not receive token-level progress. Do not put an Internalize key into an OpenAI tracing client; tracing is a separate service and credential.
The official models guide explains the explicit Chat Completions adapter, and the configuration guide covers tracing configuration. Internalize's API reference is authoritative for our supported request fields.