openai-agents-python/docs/sdk/providers.md
Mark Stuart ba3fbbf400
docs: organize SDK guides around developer tasks (#5920)
* docs: organize SDK guides and clarify examples

* fix: correct native SDK type declarations

* test: update native SDK contract fixtures

* fix: normalize persisted agent profile transport settings

* test: reconcile inherited model settings API snapshot

* test: preserve executor coverage on Windows

---------

Co-authored-by: markstuart-oai <323302876+markstuart-oai@users.noreply.github.com>
2026-11-12 21:00:58 -08:00

5 KiB

Check a custom Responses endpoint

Use NativeProvider to connect the SDK to a custom Responses endpoint. Before using that endpoint in your application, check the endpoint and model against each feature the application needs. A Chat Completions-compatible route alone is insufficient.

First test HTTP text responses, then Python tools, then strict output. Use the same endpoint and model configuration that the application will use. A successful text response does not establish tool, strict-output, image, MCP or WebSocket support.

session.capabilities reports support in the SDK configuration. It does not send a request to test the remote service. The checks below exercise the endpoint through real model requests.

Run text, Python tools and strict output separately

Each check makes live requests and can incur charges. Keep inputs synthetic and keep credentials out of logs.

  1. Install the preview wheel in the Python environment you will use for the checks.
  2. Save the script below as check_endpoint.py.
  3. Set OPENAI_BASE_URL, OPENAI_API_KEY and MODEL for the endpoint and model under test. The script passes the URL explicitly because the SDK does not read OPENAI_BASE_URL itself.
  4. Run python check_endpoint.py text, then python check_endpoint.py tools, then python check_endpoint.py strict. Each successful check prints its mode, passed:, and the final output.
import asyncio
import os
import sys

from pydantic import BaseModel

from agents import Agent, NativeProvider, function_tool


class Answer(BaseModel):
    label: str


async def main() -> None:
    if len(sys.argv) != 2:
        raise SystemExit("Usage: python check_endpoint.py text|tools|strict")
    mode = sys.argv[1]
    if mode not in {"text", "tools", "strict"}:
        raise ValueError("Choose text, tools or strict")
    calls: list[str] = []

    @function_tool
    def lookup_label() -> str:
        calls.append("lookup_label")
        return "atlas"

    async with NativeProvider(
        base_url=os.environ["OPENAI_BASE_URL"],
        api_key=os.environ["OPENAI_API_KEY"],
        supports_websockets=False,
    ) as provider:
        agent = Agent(
            instructions="Follow the requested smoke check.",
            model=os.environ["MODEL"],
            provider=provider,
            tools=[lookup_label] if mode == "tools" else [],
            output_type=Answer if mode == "strict" else str,
        )
        prompt = {
            "text": "Reply with the word atlas.",
            "tools": "Call lookup_label and report its returned label.",
            "strict": "Return label atlas in the required object.",
        }[mode]
        result = await agent.run(prompt)
        if mode == "tools":
            assert calls == ["lookup_label"], calls
        elif mode == "strict":
            assert isinstance(result.final_output, Answer)
            assert result.final_output.label == "atlas"
        else:
            assert "atlas" in result.final_output.lower()
        print(mode, "passed:", result.final_output)


if __name__ == "__main__":
    asyncio.run(main())

The checks cover only their selected cases:

Check What a pass establishes Limit
Text The endpoint returned a response containing atlas. It does not establish support for tools, structured output or other input types.
Tools The model requested the Python function and the loop completed. It does not cover every tool shape.
Strict output The SDK requested native schema output and validated this object. It does not prove server enforcement for every generation or support for every schema.

If a check fails, inspect the assertion or service error and the corresponding request. Separate a protocol failure from a model that did not follow the prompt. For example, a tool check fails if the model returns text without calling lookup_label, even when the endpoint supports tool calls.

Each agent.run() call closes its one-shot Session before the script leaves the provider context. Follow the same order with shared providers: close every Session that uses the provider before closing the provider.

Check WebSockets independently

The script forces HTTP. To check WebSockets:

  1. Pass the required HTTP cases first.
  2. Set supports_websockets=True and repeat selected cases against an endpoint that declares support.
  3. Verify the actual upgrade and response in trusted server logs or approved transport monitoring tools. The runtime selects the final transport. A successful run or websockets_allowed=True does not prove negotiation.

Record the SDK source revision, wheel version, endpoint and model settings, transport evidence and case outcomes without secrets. Repeat the relevant checks when the endpoint, model, SDK build or feature configuration changes. Add representative cases for images and any additional tool combinations your application uses.

See model connections, structured output limits and feature combinations.