OpenAI Responses API

Use OpenAI's Responses API and the Agents SDK with Morse: send the whole conversation, stream, and see what Morse refuses.

Call client.responses.create with Morse's base URL and your key, and set store to false.

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://inference.trymorse.ai/v1",
    api_key=os.environ["MORSE_API_KEY"],
)

response = client.responses.create(
    model="moonshotai/kimi-k3.1-pro",
    instructions="Answer in one sentence.",
    input="What is a TEE?",
    store=False,
)
print(response.output_text)

Every chat model serves Responses, with the same prices, privacy tiers, and failover as chat completions. For Codex, see Use Codex with a private API.

Send the whole conversation

Send every earlier turn in input: Morse stores no response, and every response returns store: false.

Python
history = [{"role": "user", "content": "What is a TEE?"}]
first = client.responses.create(model="moonshotai/kimi-k3.1-pro", input=history, store=False)

history += first.output
history.append({"role": "user", "content": "Name one."})
second = client.responses.create(model="moonshotai/kimi-k3.1-pro", input=history, store=False)

Set store to false on every request. Without it, a client may send item_reference items, which Morse refuses.

Stream a response

stream = client.responses.create(
    model="moonshotai/kimi-k3.1-pro",
    input="What is a TEE?",
    store=False,
    stream=True,
)
for event in stream:
    if event.type == "response.output_text.delta":
        print(event.delta, end="", flush=True)
  • A stream sends OpenAI's named events, each with a sequence_number from 0, and no [DONE].
  • It ends with response.completed, or with response.incomplete when the response reached max_output_tokens or a content filter.
  • The ending event carries the whole response with its usage.
  • Morse sends response.in_progress every 15 seconds while it holds back reasoning or a custom tool's input.
  • Ignore the obfuscation string in each event's data. Its random length hides the event's size.
  • A stream that fails after it starts ends with response.failed, whose response carries the error.

Tools and reasoning

  • Send function, custom, and namespace tools. Morse refuses OpenAI's built-in tools.
  • Set reasoning.effort to pick an effort. See Reasoning.
  • Set reasoning.summary to get a reasoning item, where the model sends reasoning text.
  • A temperature or top_p other than 1 reaches the provider only while Let my settings reach the model host on the key's page in the console is on.

The OpenAI Agents SDK

Turn the Agents SDK's tracing off, then give it the client. By default it uploads a trace of every run, with your prompts, tool arguments, and outputs, to api.openai.com.

import os
from agents import Agent, ModelSettings, Runner, set_default_openai_client, set_tracing_disabled
from openai import AsyncOpenAI

set_tracing_disabled(True)  # or the run's prompts and tool data go to api.openai.com

set_default_openai_client(
    AsyncOpenAI(base_url="https://inference.trymorse.ai/v1", api_key=os.environ["MORSE_API_KEY"]),
)
agent = Agent(
    name="Assistant",
    model="moonshotai/kimi-k3.1-pro",
    model_settings=ModelSettings(store=False),
)
result = Runner.run_sync(agent, "Say hello.")

OPENAI_AGENTS_DISABLE_TRACING=1 in the environment turns tracing off too. Morse refuses the SDK's hosted tools, such as web search and file search, since they run on OpenAI's servers.

What Morse refuses

Each of these returns 400 unsupported_parameter, which names the parameter.

SentWhat to do
previous_response_id, conversation, prompt, or store: trueSend the whole conversation in input.
item_referenceSet store to false.
background: true, context_management, or a truncation other than disabledLeave them out.
Built-in tools, such as web_search, file_search, code_interpreter, and mcpDefine the tool yourself, as a function tool.
A tool_choice of allowed_tools or a built-in toolName a function or custom tool, or a mode.
File inputs, and images linked by URL or file_idSend an image as a base64 data URL.
A text.format other than text, json_object, or json_schemaSee Structured outputs.

Morse ignores include, prompt_cache_key, service_tier, text.verbosity, user, and client_metadata. See Create a response.