Skip to content

feat(answer-v2)!: align SDK types with the /v2/answer API - #10

Merged
M-kasinski merged 1 commit into
mainfrom
fix/align-sdk-to-answer-v2-api
Jul 15, 2026
Merged

feat(answer-v2)!: align SDK types with the /v2/answer API#10
M-kasinski merged 1 commit into
mainfrom
fix/align-sdk-to-answer-v2-api

Conversation

@M-kasinski

Copy link
Copy Markdown
Collaborator

Context

The Answer V2 API (POST /v2/answer) has evolved and the SDK's type surface had drifted from it. This PR realigns the published types with the current API contract.

Changes

Request (AnswerV2Input)

  • language: now accepts 'fr' | 'en' (was 'fr' only); default stays 'fr'
  • Remove the obsolete style field — it is no longer accepted by the API and sending it results in a 400
  • sources: doc fixed (max 10)
  • filter: example fixed (example.com — bare domain, no www/scheme)

Non-streaming response (AnswerV2Result)

  • Remove finish_reason and generation_ms — not returned by the non-streaming response

Stream events (AnswerV2Event)

  • Remove the usages stream event — it is not emitted over the SSE stream, so clients never receive it

README, examples and tests updated accordingly.

Note on streaming usages

Dropping the usages stream event matches current behavior. Streaming usage reporting will be added later, end to end.

Validation

  • ✅ typecheck (src + examples)
  • ✅ build (tsup)
  • ✅ 13/13 tests (vitest)

⚠️ Breaking change

Removes style (input), finish_reason/generation_ms (result) and the usages stream event.

🤖 Generated with Claude Code

Bring the SDK type surface in line with the current api-staan Answer V2
endpoint:

- language: accept 'fr' | 'en' (was 'fr' only); default stays 'fr'
- drop the obsolete `style` input field — it no longer exists on the API
  and, with forbidNonWhitelisted validation, sending it yields a 400
- AnswerV2Result: drop `finish_reason` and `generation_ms` (never
  returned by the non-streaming response)
- AnswerV2Event: drop the `usages` stream event — the API filters usage
  out of the SSE stream, so clients never receive it
- fix `sources` max (10, not 20) and the `filter` domain example

Docs, examples and tests updated to match.

BREAKING CHANGE: `style` is removed from AnswerV2Input; `finish_reason`
and `generation_ms` are removed from AnswerV2Result; the `usages` stream
event is removed from AnswerV2Event.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@M-kasinski
M-kasinski merged commit 47147b2 into main Jul 15, 2026
1 check passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant