Skip to content

[FEATURE] docs: add a Responses API example for create_response and create_response_stream #175

Description

Summary

Domain: Responses API (OpenAI-compatible POST /responses). The client exposes create_response and create_response_stream, and the package exports the related models (Response, ResponseStreamEvent, ResponseInputItem, ResponseTool, ResponseOutputMessage, ResponseOutputText, ResponseFunctionToolCall and more), but no example demonstrates them. There is no examples/responses/ directory, and the root README.md only names create_response_stream once, in the error-handling paragraph. The request and response shapes differ from chat completions (a string or item list as input, max_output_tokens, a flattened ResponseTool, a typed output item list and typed stream events), so a user cannot reasonably use the feature from the README alone.

Acceptance Criteria

  • Add examples/responses/main.py that calls client.create_response(model=..., input="...", max_output_tokens=...) and prints the text by walking response.output for ResponseOutputMessage items and their ResponseOutputText content.
  • In examples/responses/main.py, call client.create_response_stream(...) and print event.delta for events whose type is response.output_text.delta, showing that events arrive as typed ResponseStreamEvent objects.
  • In examples/responses/main.py or its README, show a multi-turn input built from ResponseInputItem objects and a function tool defined with ResponseTool(name=..., description=..., parameters=FunctionParameters(...)), reading the call back from a ResponseFunctionToolCall output item.
  • Add examples/responses/README.md with usage, the note that providers without Responses API support return a 400, and the env var used for the model.
  • Add a "Responses API" section to the root README.md with standard and streaming snippets, and list the new example in the README.md "Examples" section and in examples/README.md.

Activity

  1. edenreich commented on Nov 17, 2026

    @edenreich
    Contributor

    @claude can you work on this?

  2. inference-gateway-maintainer commented on Nov 17, 2026

    @inference-gateway-maintainer
    ContributorAuthor

    Claude finished @edenreich's task in 2m 41s —— View job • feat/issue-175-20261117-1939 • [Create PR ➔](https://github.com/inference-gateway/python-sdk/compare/main...feat/issue-175-20261117-1939?quick_pull=1&title=Issue%20%23175%3A%20Changes%20from%20Claude&body=This%20PR%20addresses%20issue%20%23175%0A%0AGenerated%20with%20%5BClaude%20Code%5D(https%3A%2F%2Fclaude.ai%2Fcode)


    Responses API example added - PR #180

    • Track issue on Roadmap board (In progress, then QA)
    • Gather context (client, models, existing examples)
    • Add examples/responses/main.py
    • Add examples/responses/README.md
    • Update root README.md and examples/README.md
    • Lint, commit, open PR

    PR: #180

    What changed:

    • examples/responses/main.py has three demos:
      • Standard: calls create_response(model, input="...", max_output_tokens=...), then gets the text by walking response.output for ResponseOutputMessage items and their ResponseOutputText parts.
      • Streaming: calls create_response_stream(...) and prints event.delta for each response.output_text.delta event.
      • Tools: sends a multi-turn input built from ResponseInputItem objects with a flattened ResponseTool(..., parameters=FunctionParameters(...)), then reads the calls back from ResponseFunctionToolCall output items.
    • examples/responses/README.md covers usage, code snippets, the note that providers without Responses API support return a 400, and the LLM_NAME env var (default openai/gpt-4o).
    • The root README.md has a new "Responses API" section with standard and streaming snippets. The example is now listed in both the root README.md and examples/README.md.

    Checks:

    • task lint passes (black, isort and mypy on examples/).
    • task test passes: 53 passed, 1 xfailed.
    • I ran the example's parsing helpers offline against a hand-built Response, and they read it correctly.
    • I did not run the example against a live gateway.

    I didn't open a docs ticket because only the examples and README changed. The SDK's public behavior is the same.
    | Branch

  3. moved this from Todo to In progress in 2026on Nov 17, 2026
  4. moved this from In progress to QA in 2026on Nov 17, 2026
  5. moved this from QA to Done in 2026on Nov 17, 2026
  6. inference-gateway-releaser commented on Nov 17, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.26.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementreleased

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions