Skip to Content
GuidesSSE Streaming

SSE Streaming

The Career API supports Server-Sent Events (SSE) streaming for AI-powered endpoints. This lets you receive results in real-time as they’re generated.

Streaming Endpoints

EndpointDescription
POST /v1/tailorResume tailoring suggestions
POST /v1/cover-letters/generateCover letter generation

How to Enable

Add Accept: text/event-stream to your request headers:

curl https://api.laddro.com/v1/tailor \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -H "Accept: text/event-stream" \ -d '{ "resumeId": "res_abc123", "jobDescription": "..." }'

Event Format

Events follow the SSE specification:

data: {"type":"section","section":"summary","content":"Experienced engineer..."} data: {"type":"section","section":"experience","content":"..."} data: {"type":"done"}

Each event is a JSON object with:

FieldTypeDescription
typestringsection or done
sectionstringResume section name (when type is section)
contentstringGenerated content

Implementation Examples

JavaScript (Browser)

const response = await fetch('https://api.laddro.com/v1/tailor', { method: 'POST', headers: { 'x-api-key': apiKey, 'Content-Type': 'application/json', 'Accept': 'text/event-stream' }, body: JSON.stringify({ resumeId, jobDescription }) }) const reader = response.body.getReader() const decoder = new TextDecoder() while (true) { const { done, value } = await reader.read() if (done) break const text = decoder.decode(value) const lines = text.split('\n') for (const line of lines) { if (line.startsWith('data: ')) { const event = JSON.parse(line.slice(6)) if (event.type === 'done') return console.log(event.section, event.content) } } }

TypeScript SDK

for await (const event of client.tailor( { resumeId, jobDescription }, { stream: true } )) { console.log(event.section, event.content) }

Python SDK

for event in client.tailor( resume_id=resume_id, job_description=jd, stream=True ): print(event.section, event.content)

Node.js (Raw)

import { createParser } from 'eventsource-parser' const response = await fetch('https://api.laddro.com/v1/tailor', { method: 'POST', headers: { 'x-api-key': process.env.LADDRO_API_KEY, 'Content-Type': 'application/json', 'Accept': 'text/event-stream' }, body: JSON.stringify({ resumeId, jobDescription }) }) const parser = createParser(event => { if (event.type === 'event') { const data = JSON.parse(event.data) if (data.type === 'done') return process.stdout.write(data.content) } }) for await (const chunk of response.body) { parser.feed(new TextDecoder().decode(chunk)) }

Error Handling

If an error occurs during streaming, the stream will emit an error event:

data: {"type":"error","message":"Rate limit exceeded","statusCode":429}

Always handle the error event type in your stream consumer.

Last updated on