Skip to content

OpenAI Compatible API

Writ edited this page Jul 28, 2026 · 1 revision

OpenAI-compatible API

A workflow can be served as an OpenAI-compatible model. Any client or SDK that speaks the OpenAI chat API can point at it with a base-URL change — no new integration, no bespoke client.

Endpoints

Per workflow:

POST /api/streaming/workflows/{workflow_id}/v1/chat/completions
GET  /api/streaming/workflows/{workflow_id}/v1/models
POST /api/streaming/workflows/{workflow_id}/v1/responses

And per live session:

POST /api/streaming/sessions/{session_key}/v1/chat/completions
GET  /api/streaming/sessions/{session_key}/v1/models
POST /api/streaming/sessions/{session_key}/v1/responses

Enabling it

Open the workflow → SettingsOpenAI-compatible model → on.

You can then set:

Setting What it does
Default handler Which handler each chat message invokes.
Response field Which field of the handler's result becomes the reply.
Model name The id returned by /v1/models.
Description, Version Model card metadata.
Capabilities Vision, tool calling, streaming, file upload.
Limits Context window, max output tokens.

Using it

from openai import OpenAI

client = OpenAI(
    base_url="https://writ.example.com/api/streaming/workflows/12/v1",
    api_key="wt_...",
)
resp = client.chat.completions.create(
    model="streaming",
    messages=[{"role": "user", "content": "What is the current price?"}],
)

The API key is an ordinary Writ key — see scopes.

When to reach for this

It suits workflows that are conversational or multi-turn, where a caller wants to keep asking against a live browser session rather than fire one shot and stop. For a plain "run it and give me the data" integration, the REST endpoint is simpler.

Sessions

Streaming lists live sessions with their handlers and events. A session holds a browser open across calls, so state persists between messages. Session lifetime, concurrency and persistence are configured in the same Settings tab.

Clone this wiki locally