Skip to content

fix(api): align ChatCompletionCustomToolParam structure with API spec - #2765

Closed
thromel wants to merge 1 commit into
openai:mainfrom
thromel:fix/custom-tool-param-structure
Closed

fix(api): align ChatCompletionCustomToolParam structure with API spec#2765
thromel wants to merge 1 commit into
openai:mainfrom
thromel:fix/custom-tool-param-structure

Conversation

@thromel

@thromel thromel commented Dec 4, 2025

Copy link
Copy Markdown

Summary

  • Fixes the ChatCompletionCustomToolParam type definition to match the actual API structure
  • Removes incorrect nesting (custom wrapper object and format.grammar wrapper)
  • Reuses the shared CustomToolInputFormat type (same as Responses API)

Problem

The Chat Completions API custom tool type had incorrect nesting that didn't match the actual API structure:

Before (incorrect):

{
    "type": "custom",
    "custom": {  # ← extra nesting
        "name": "tool_name",
        "format": {
            "type": "grammar",
            "grammar": {  # ← extra nesting
                "syntax": "lark",
                "definition": "..."
            }
        }
    }
}

After (correct, matching API docs):

{
    "type": "custom",
    "name": "tool_name",
    "format": {
        "type": "grammar",
        "syntax": "lark",
        "definition": "..."
    }
}

Test plan

  • Verified type structure now matches CustomToolParam from Responses API
  • Verified imports work correctly with shared CustomToolInputFormat type

Fixes #2667

The Chat Completions API custom tool type had incorrect nesting that
didn't match the actual API structure. The type expected `name`,
`description`, and `format` to be nested inside a `custom` object,
and `syntax`/`definition` to be nested inside `format.grammar`.

The correct structure (matching the Responses API and documentation)
has these fields at the top level and reuses the shared
CustomToolInputFormat type.

Fixes #2667
@thromel
thromel requested a review from a team as a code owner December 4, 2025 09:59
@RobertCraigie

Copy link
Copy Markdown
Contributor

#2667 (comment)

@thromel
thromel deleted the fix/custom-tool-param-structure branch December 7, 2025 19:57
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.

Under the gpt5 model, the completion interface cannot utilize the custom tool's large capability

2 participants