Skip to main content

Modules

Parlyr

Conversational NLP — natural language to extraction plans

3 min read


Parlyr parses natural-language requests into an intent (what to do, on which URL, with which entities) and holds interactive chat sessions.

For complex multi-step workflows, consider NEXUS instead. See the Parlyr vs NEXUS guide for a comparison.

parse

result = client.parlyr.parse(
    "Extract all product names, prices, and ratings",
)
print(result.intent, result.confidence, result.detected_url)

POST …/parlyr/parse returns intent, confidence, entities, source, tier, requires_action, clarification_needed, reasoning and detected_url.

chat (Server-Sent Events)

POST /api/v1/organizations/{org_id}/parlyr/chat with {"session_id": "…", "message": "…"} runs one turn of a conversation and answers with a stream of Server-Sent Events. Reuse the same session_id for the next turn. Each event's data is a JSON object:

{ "type": "text", "content": "…", "data": null, "actions": null, "timestamp": "2026-10-28T10:15:00" }

| Event | Meaning | |-------|---------| | thinking | The message is being analysed | | interpretation | The plan for the request; data holds it, actions the choices (start, cancel) | | progress | Progress of a job the turn started | | results | Extracted data, with export actions | | error | A friendly error with recovery options | | warning | A sanity-check warning (it may block the plan) | | auth_required | The site needs credentials | | mfa_required | The site needs an MFA code | | clarification | The assistant asks a question (content) | | export_ready | An export file is ready | | text | A plain text reply (content) | | end | The turn is over; the stream closes (data is {}) |

chat collects a turn into one result:

turn = client.parlyr.chat(session_id="my-session", message="Find all prices on example.com")
print(turn.ok, turn.response)        # response: the text and clarification contents
print(turn.interpretation)           # data of the interpretation event, or None
for r in turn.results:               # data of each results event
    print(r)
print(turn.errors, turn.warnings)    # error events are collected, not raised
const turn = await client.parlyr.chat('my-session', 'Find all prices on example.com');
console.log(turn.ok, turn.response, turn.interpretation, turn.results, turn.errors);

intent is read from the interpretation's data; the API does not send one today, so it is usually empty.

chat_stream / chatStream yield the events as they arrive, with type, content, data, actions and timestamp, and stop at end:

for event in client.parlyr.chat_stream("sess-abc", "Find all prices on example.com"):
    if event.type in ("text", "clarification"):
        print(event.content)
    elif event.type == "error":
        print("Error:", event.content)

# AsyncKloakd keeps the context-manager form:
async with client.parlyr.chat_stream(session_id="sess-abc", message="Refine") as events:
    async for event in events:
        print(event.type, event.content)
for await (const event of client.parlyr.chatStream('sess-abc', 'Find all prices on example.com')) {
  if (event.type === 'text' || event.type === 'clarification') console.log(event.content);
}

Session state

GET /api/v1/organizations/{org_id}/parlyr/chat/{session_id}/events returns a session's state as one session_info event (session_id, organization_id, message_count, pending_action, has_results, is_executing), then end. It does not replay earlier events: to continue, post the next message to …/parlyr/chat with the same session_id. An unknown session answers 404.

delete_session

client.parlyr.delete_session("sess-abc123")

DELETE …/parlyr/chat/{session_id} answers 204, or 404 for an unknown session.

Next steps

Was this page helpful?