Skip to content

Add model field to CreateResponse for embeddings #634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

bemtorres
Copy link
Contributor

@bemtorres bemtorres commented Jul 22, 2025

What:

  • Bug Fix
  • New Feature

Description:

This pull request adds support for the model field in the CreateResponse class for embeddings.

The OpenAI API's embeddings response includes a model property, but it wasn’t being exposed in the PHP client. This update fixes that by adding the model field to the response class, so users can now access it directly—just like the API intends.

  • Added the model property to the CreateResponse class.
  • Updated the constructor, from method, and toArray method to handle the model field.
  • Adjusted related tests to check for the presence of the model property.

https://platform.openai.com/docs/api-reference/embeddings/create

reposnse

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "embedding": [
        0.0023064255,
        -0.009327292,
        .... (1536 floats total for ada-002)
        -0.0028842222,
      ],
      "index": 0
    }
  ],
  "model": "text-embedding-ada-002",
  "usage": {
    "prompt_tokens": 8,
    "total_tokens": 8
  }
}

@iBotPeaches
Copy link
Collaborator

thanks! If you remove inline comments and add to doc block this should be good.

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.

This property needs to be added as nullable (or missing) as parity with the other providers don't return this.

Then should be good to go

@iBotPeaches iBotPeaches added the enhancement New feature or request label Jul 28, 2025
@iBotPeaches iBotPeaches added this to the v0.15.0 milestone Jul 28, 2025
@iBotPeaches iBotPeaches merged commit e790121 into openai-php:main Jul 28, 2025
12 checks passed
@iBotPeaches
Copy link
Collaborator

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants