Skip to content

Commit 759da45

Browse files
committed
Sync open source content 🐝 (from 591570e61e378285b5b84d8ee08ec50b679187c9)
1 parent ecc432d commit 759da45

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

docs/customize/runtime/server-sent-events.mdx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,12 @@ for await (const event of response.chatStream) {
287287
}
288288
```
289289

290-
#### Alternative: Single method with Python overloads
290+
#### Alternative: Single method with overloads
291291

292-
Instead of using URL fragments to create separate methods, you can define a single endpoint that supports both response types. Since `inferSSEOverload` defaults to `true` in your `gen.yaml`, Python SDKs will automatically generate a single overloaded method that provides type safety based on the `stream` parameter value:
292+
Instead of using URL fragments to create separate methods, you can define a single endpoint that supports both response types. Since `inferSSEOverload` defaults to `true` in your `gen.yaml`, TypeScript and Python SDKs will automatically generate a single overloaded method that provides type safety based on the `stream` parameter value:
293293

294294
<Callout title="Note" type="info">
295-
The `inferSSEOverload` feature is currently Python-specific, with support for other languages planned for future releases.
295+
The `inferSSEOverload` feature is currently supported in TypeScript and Python, with support for other languages planned for future releases.
296296
</Callout>
297297

298298
```yaml
@@ -337,7 +337,23 @@ components:
337337
# SSE event schema
338338
```
339339

340-
This generates type-safe Python methods:
340+
This generates type-safe methods in both TypeScript and Python:
341+
342+
```typescript
343+
import { SDK } from '@speakeasy/sdk';
344+
345+
const sdk = new SDK();
346+
347+
// Non-streaming - returns ChatResponse
348+
const response = await sdk.chat.create({ prompt: "Hello", stream: false });
349+
console.log(response.content);
350+
351+
// Streaming - returns AsyncIterable<ChatStream>
352+
const stream = await sdk.chat.create({ prompt: "Hello", stream: true });
353+
for await (const event of stream) {
354+
process.stdout.write(event.data);
355+
}
356+
```
341357

342358
```python
343359
from myapi import SDK

0 commit comments

Comments
 (0)