Skip to content

docs: document SSE metadata access in generated SDKs#5998

Open
fern-api[bot] wants to merge 11 commits into
mainfrom
devin/1782499352-sse-metadata-docs
Open

docs: document SSE metadata access in generated SDKs#5998
fern-api[bot] wants to merge 11 commits into
mainfrom
devin/1782499352-sse-metadata-docs

Conversation

@fern-api

@fern-api fern-api Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds documentation for accessing SSE protocol metadata (event ID, event type, retry interval) in generated SDKs.

New "Server-sent events" section in generated-sdk.mdx (SDK user features):

  • Default streaming iteration examples (TypeScript, Python, Go)
  • Metadata-aware iteration via stream.withMetadata() (TS >= 3.73.0) and stream.RecvEvent() / stream.LastEventID() (Go >= 1.32.0)
  • Python tab in metadata section with explicit note that metadata access is not yet available
  • Stream resumption pattern using Last-Event-ID header

All three languages (TypeScript, Python, Go) appear in both code blocks for tab consistency. Verified against generator source:

  • Go: Stream[T].Recv() for data, Stream[T].RecvEvent() for StreamEvent[T] with SseEventMeta (ID, Event, Retry)
  • Python: EventSource.iter_sse() yields ServerSentEvent internally but generated client methods only expose parsed data — no user-facing metadata API yet
  • TypeScript: stream.withMetadata()AsyncIterable<ServerSentEvent<T>>

Cross-references added from OpenAPI SSE page, Fern Definition SSE page, and SDK capabilities page. SSE added to Vale Acronyms.yml and Headings.yml exception lists.

Requested by: Fern Support

Link to Devin session: https://app.devin.ai/sessions/24f08a389b784ac297acec6909e82bf2

…rated SDKs

Add Server-sent events section to SDK user features page documenting:
- Default streaming iteration (TypeScript, Python)
- SSE metadata access via .withMetadata() (TypeScript) and RecvEvent() (Go)
- ServerSentEvent fields: id, data, event, retry
- Stream resumption with event ID and Last-Event-ID header
- Backward compatibility

Cross-reference from OpenAPI and Fern Definition SSE pages.
Update capabilities page to link to SDK-side SSE docs.

Co-Authored-By: bot_apk <apk@cognition.ai>
@fern-api fern-api Bot requested a review from devalog as a code owner June 26, 2026 18:45
@fern-api

fern-api Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Requested by: devin.logan
Slack thread: View conversation

```

<Note>
For SDK-side usage of SSE metadata (event ID, event type, retry interval), see [Accessing SSE metadata](/learn/sdks/deep-dives/sdk-user-features#accessing-sse-metadata).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'SSE' has no definition.

```

<Note>
For SDK-side usage of SSE metadata (event ID, event type, retry interval), see [Accessing SSE metadata](/learn/sdks/deep-dives/sdk-user-features#accessing-sse-metadata).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'SSE' has no definition.

```

<Note>
For SDK-side usage of SSE metadata (event ID, event type, retry interval), see [Accessing SSE metadata](/learn/sdks/deep-dives/sdk-user-features#accessing-sse-metadata).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'SSE' has no definition.

```

<Note>
For SDK-side usage of SSE metadata (event ID, event type, retry interval), see [Accessing SSE metadata](/learn/sdks/deep-dives/sdk-user-features#accessing-sse-metadata).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'SSE' has no definition.

Comment thread fern/products/sdks/capabilities.mdx Outdated
- **Webhook signature verification**: Verify the signature of incoming webhook requests. [Learn more](/learn/sdks/deep-dives/webhook-signature-verification)
- **Idempotency headers**: Built-in protection against duplicate submissions. [Learn more](/sdks/deep-dives/idempotency)
- **Server-sent events**: Stream JSON data from your server to your client. [Learn more](/api-definitions/openapi/endpoints/sse)
- **Server-sent events**: Stream JSON data from your server to your client, with opt-in access to SSE metadata (event ID, event type, retry). [Learn more](/learn/sdks/deep-dives/sdk-user-features#server-sent-events)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'SSE' has no definition.

</CodeBlock>
</CodeBlocks>

### Accessing SSE metadata

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] reported by reviewdog 🐶
[FernStyles.Headings] 'Accessing SSE metadata' should use sentence-style capitalization.

</CodeBlock>
</CodeBlocks>

### Accessing SSE metadata

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'SSE' has no definition.


### Accessing SSE metadata

To access SSE protocol fields (event ID, event type, retry interval) alongside the parsed data, use the metadata-aware iteration methods:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'SSE' has no definition.

</CodeBlock>
</CodeBlocks>

This is useful for capturing the event ID to resume a stream later via the standard SSE `Last-Event-ID` header. Store the last received ID as you iterate, then pass it back to the server on reconnection.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [vale] reported by reviewdog 🐶
[FernStyles.Acronyms] 'SSE' has no definition.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

- Add Go tab to default iteration code block (stream.Recv pattern)
- Add Python tab to metadata code block with note that metadata access
  is not yet available in Python
- Rename heading to 'Accessing server-sent event metadata' for clarity
- Update cross-reference links to match new anchor
- Define SSE in-context as 'server-sent event (SSE)' in cross-refs
- Add SSE to Vale Acronyms and Headings exception lists
- Update Note to clarify Python support status

Co-Authored-By: Devin Logan <devinannlogan@gmail.com>
</CodeBlock>
<CodeBlock title="Python">
```python
# Python does not yet expose SSE metadata to callers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[Microsoft.Contractions] Use 'doesn't' instead of 'does not'.

Default iteration is unchanged, so these methods are fully backward compatible.

<Note>
Metadata access requires TypeScript SDK generator version 3.73.0+ or Go SDK generator version 1.32.0+. Python support is not yet available.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [vale] reported by reviewdog 🐶
[Microsoft.Contractions] Use 'isn't' instead of 'is not'.

devalog and others added 9 commits June 27, 2026 13:30
Python SDK ships ServerSentEvent dataclass in core.http_sse with id,
event, data, and retry fields. Customer thread confirms users import
and use this class directly. Updated docs to include Python alongside
TypeScript (withMetadata) and Go (RecvEvent) rather than stating
Python support is not yet available.

Co-Authored-By: Devin Logan <devinannlogan@gmail.com>
- New page at deep-dives/sse-metadata.mdx with code blocks for
  TypeScript (withMetadata), Go (RecvEvent), and Python (ServerSentEvent)
- sdk-user-features SSE section reduced to one-liner + link
- Navigation YAML updated with new page in SDK design section
- Cross-references updated: OpenAPI SSE, Fern Definition SSE,
  capabilities page all point to new canonical page

Co-Authored-By: Devin Logan <devinannlogan@gmail.com>
Co-Authored-By: Devin Logan <devinannlogan@gmail.com>
Python does not have a high-level metadata iteration API (no
withMetadata/RecvEvent equivalent). The ServerSentEvent class exists
in core.http_sse but the generated client only surfaces parsed data.
Only show TypeScript and Go in the metadata-aware iteration block.

Also adds ## Default iteration heading for section symmetry.

Co-Authored-By: Devin Logan <devinannlogan@gmail.com>
Co-Authored-By: Devin Logan <devinannlogan@gmail.com>
- Changed 'Python SDKs support default iteration only' to 'Python does
  not yet expose an equivalent method' — accurate without implying the
  metadata is unreachable (ServerSentEvent exists in core.http_sse)
- Removed 'TypeScript and Go' from prose sentence to avoid restating
  what the Note already covers

Co-Authored-By: Devin Logan <devinannlogan@gmail.com>
…on section

Co-Authored-By: Devin Logan <devinannlogan@gmail.com>
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.

2 participants