Skip to content

Add per-token logprobs content schema to LogprobsPart#245

Open
TechnoFinch wants to merge 1 commit intomainfrom
mark/fix-logprobs-schema
Open

Add per-token logprobs content schema to LogprobsPart#245
TechnoFinch wants to merge 1 commit intomainfrom
mark/fix-logprobs-schema

Conversation

@TechnoFinch
Copy link
Copy Markdown

@TechnoFinch TechnoFinch commented Apr 22, 2026

Summary

  • Adds LogprobsToken and LogprobsTokenTopLogprob schema types to describe the per-token logprobs structure the API already returns
  • Adds content field to LogprobsPart referencing the new types
  • All fields optional for backwards compatibility

Problem

The chat completions API returns logprobs in a content array with nested top_logprobs per token, but the OpenAPI spec only describes the legacy flat format (tokens, token_logprobs, token_ids). This causes the Stainless-generated Python SDK to silently drop content and per-token top_logprobs during deserialization. This brings back lost functionality from 1.x.x to 2.x.x.

Verification

Confirmed via raw curl that the API returns the content[].top_logprobs[] structure. The spec change matches the actual response format exactly.

Fixes https://linear.app/together-ai/issue/ENG-86462/fix-logprob-misalignment-with-open-sdk

The API returns per-token log probability information in a content array
with nested top_logprobs, but the OpenAPI spec did not describe this
structure. This caused the generated Python SDK to silently drop the
content and per-token top_logprobs data during deserialization.

Adds LogprobsToken and LogprobsTokenTopLogprob schema types, and a
content field to LogprobsPart. All fields are optional for backwards
compatibility.

Fixes https://linear.app/together-ai/issue/ENG-86462/fix-logprob-misalignment-with-open-sdk
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

✱ Stainless preview builds

This PR will update the togetherai SDKs with the following commit messages.

go

feat(api): add content field and nested logprob models to LogProbs

openapi

feat(api): add content field and token types to LogprobsPart model

python

feat(api): add content field and nested models to LogProbs

terraform

chore(internal): regenerate SDK with no functional changes

typescript

feat(api): add content field to LogProbs in completions

Edit this comment to update them. They will appear in their respective SDK's changelogs.

togetherai-python studio · code · diff

Your SDK build had at least one "warning" diagnostic, but this did not represent a regression.
generate ⚠️build ✅lint ✅test ⏭️

pip install https://pkg.stainless.com/s/togetherai-python/509d79c92b5760e68b8b528bd6f935cb11fdc854/together-2.9.0-py3-none-any.whl
togetherai-openapi studio · code · diff

Your SDK build had at least one "note" diagnostic, but this did not represent a regression.
generate ✅

togetherai-typescript studio · code · diff

Your SDK build had at least one "warning" diagnostic, but this did not represent a regression.
generate ⚠️build ✅ (prev: build ⏭️) → lint ✅ (prev: lint ⏭️) → test ❗

npm install https://pkg.stainless.com/s/togetherai-typescript/3e3bd06836c167f5b6b073566d7b24b483a2bd01/dist.tar.gz
togetherai-go studio · code · diff

Your SDK build had at least one "note" diagnostic, but this did not represent a regression.
generate ✅build ✅ (prev: build ⏭️) → lint ✅test ❗

go get github.com/stainless-sdks/togetherai-go@c718a0e994b9c3119d50537748c327f138a80428
togetherai-terraform studio · code · diff

Your SDK build had at least one "note" diagnostic, but this did not represent a regression.
generate ✅lint ✅test ✅


This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-04-22 01:25:59 UTC

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.

1 participant