Skip to main content
Flowyte exposes an OpenAI-compatible chat completions endpoint. If your code already uses an OpenAI client library, you can talk to a Flowyte agent by changing two things: the base URL and the model. The model is your agent id, and the agent’s knowledge, skills, and guardrails all apply to the response. All paths are relative to https://builder.flowyte.com/api/v1.
Authenticate with your secret key Authorization: Bearer flowyte_sk_… (scope chat:write). This endpoint serves the agent’s published version.

What you’ll use

ActionEndpointScope
Create a completionPOST /chat/completionschat:write

The base-URL swap

Set the client’s base URL to https://builder.flowyte.com/api/v1, the API key to your flowyte_sk_…, and pass the agent id as model. The SDK appends /chat/completions for you.
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.FLOWYTE_API_KEY,            // flowyte_sk_…
  baseURL: "https://builder.flowyte.com/api/v1",  // ← the only swap
});

const completion = await client.chat.completions.create({
  model: "agt_123",                                // ← your agent id
  messages: [{ role: "user", content: "Do you ship to Canada?" }],
});

console.log(completion.choices[0].message.content);
The response is the standard completion shape: read the reply from choices[0].message.content.

Streaming

Set stream: true and the endpoint returns OpenAI-style SSE chunks — data: {choices:[{delta:{content}}]} … terminated by data: [DONE] — so an OpenAI SDK’s streaming mode works unchanged.
const stream = await client.chat.completions.create({
  model: "agt_123",
  messages: [{ role: "user", content: "Summarize your return policy." }],
  stream: true,
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

What’s read, and what isn’t

  • Only model, messages, stream, and user are used. The agent’s own configuration governs its behavior — sampling, tools, and system prompt come from the published agent, so request-level overrides for those are ignored.
  • model must be a real agent id, not an OpenAI model name. An unknown id returns a 400.
  • Roles system, user, assistant, and tool are accepted in messages.
Need session state, tool-call events, or quick replies? Use the native chat API instead: POST /chat/sessions then POST /chat/sessions/{id}/messages with stream: true. For an in-browser widget, mint a publishable key — see Embed the chat widget.
Related: Agents · Authentication