Skip to content

Conversation

@carvemerson
Copy link
Contributor

What:

  • Bug Fix
  • New Feature
  • README update

Description:

Fix tool call example on README

Fix tool call example
Copy link
Collaborator

@iBotPeaches iBotPeaches left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll admit I haven't used Chat Completion since Response API came out, but this seems wrong. So can you provide why you think this needs to be different? Is it the case that OpenAI docs are wrong?

I'm looking at this sample

curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
  "model": "gpt-4.1",
  "messages": [
    {
      "role": "user",
      "content": "What is the weather like in Boston today?"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_current_weather",
        "description": "Get the current weather in a given location",
        "parameters": {
          "type": "object",
          "properties": {
            "location": {
              "type": "string",
              "description": "The city and state, e.g. San Francisco, CA"
            },
            "unit": {
              "type": "string",
              "enum": ["celsius", "fahrenheit"]
            }
          },
          "required": ["location"]
        }
      }
    }
  ],
  "tool_choice": "auto"
}'

@thomaspapanikolaou
Copy link

thomaspapanikolaou commented Sep 29, 2025

There are differences in the tools schema when moving to the Responses API, acknowledge d here

https://platform.openai.com/docs/guides/migrate-to-responses

Specifically, the new schema is shown here

https://platform.openai.com/docs/guides/function-calling

So the README is correct for the Chat Resource. You need a different schema for the Responses resource (no example provided today, except the built-in web_search_preview tool).

I hope this helps.

@iBotPeaches
Copy link
Collaborator

Okay so that was my confusion. You wanted to add an example for function call for Responses API, but edited the Chat completion one on accident?

@thomaspapanikolaou
Copy link

I guess that's what Emerson (the originator) meant. This is Thomas here Connor, trying to help.

@carvemerson
Copy link
Contributor Author

carvemerson commented Sep 29, 2025

Sorry for the confusion. My goal was to provide an example of how to use the function tool, but I didn't noticed that it was on the wrong place. I’ve reverted my earlier change and added a new section with the example. Hopefully, this will be useful for other developers.

@carvemerson
Copy link
Contributor Author

Thx for the feedback, I did the change.

@iBotPeaches iBotPeaches merged commit d95eda4 into openai-php:main Oct 1, 2025
12 checks passed
@iBotPeaches
Copy link
Collaborator

thanks!

@iBotPeaches iBotPeaches added this to the v0.17.0 milestone Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants