Skip to content

fix: default tool call type to function for Mistral compatibility#744

Merged
iBotPeaches merged 1 commit intoopenai-php:mainfrom
ivanmestre:fix-undefined-array-key-type-mistral
Feb 25, 2026
Merged

fix: default tool call type to function for Mistral compatibility#744
iBotPeaches merged 1 commit intoopenai-php:mainfrom
ivanmestre:fix-undefined-array-key-type-mistral

Conversation

@ivanmestre
Copy link
Contributor

What:

  • Bug Fix
  • New Feature

Description:

The Mistral API currently omits the type attribute in its tool call responses, which causes an Undefined array key "type" exception. This commit defaults the missing type to 'function' (the standard supported type per OpenAI documentation) to prevent runtime errors and ensure broader compatibility with OpenAI-compatible APIs.

Related:

Fixes #397

The Mistral API currently omits the `type` attribute in its tool call
responses, which causes an `Undefined array key "type"` exception.
This commit defaults the missing `type` to `'function'` (the standard
supported type per OpenAI documentation) to prevent runtime errors
and ensure broader compatibility with OpenAI-compatible APIs.

Fixes openai-php#397
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.

Debated in my head - fine with defaulting this to function

@iBotPeaches iBotPeaches added the Non-OpenAI Model Not an OpenAI Model. label Feb 25, 2026
@iBotPeaches iBotPeaches merged commit 7871ffb into openai-php:main Feb 25, 2026
14 checks passed
@iBotPeaches iBotPeaches added this to the v0.20.0 milestone Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Non-OpenAI Model Not an OpenAI Model.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: MistralAI- Undefined array key "type"

2 participants