Skip to main content

SkillFlaw TypeScript integration

SkillFlaw does not currently ship a repository-owned TypeScript SDK. The recommended TypeScript integration paths are:

  1. call the SkillFlaw HTTP API directly from fetch, axios, or another HTTP client
  2. use the OpenAI JavaScript client against SkillFlaw's OpenAI-compatible endpoint at /api/v1/responses

That approach matches the current backend implementation and stays aligned with the generated snippets available in Share → API access.

Option 1: call /api/v1/run/{flow_id_or_alias} directly

Use this option when you want the native SkillFlaw run payload, including input_value, input_type, output_type, tweaks, and session_id.


_31
const baseUrl = "http://localhost:7860";
_31
const apiKey = process.env.SKILLFLAW_API_KEY!;
_31
const flowId = "YOUR_FLOW_ID";
_31
_31
async function runFlow() {
_31
const response = await fetch(`${baseUrl}/api/v1/run/${flowId}`, {
_31
method: "POST",
_31
headers: {
_31
"Content-Type": "application/json",
_31
"x-api-key": apiKey,
_31
},
_31
body: JSON.stringify({
_31
input_value: "Hello from TypeScript",
_31
input_type: "chat",
_31
output_type: "chat",
_31
tweaks: {
_31
model_name: "gpt-4o-mini",
_31
},
_31
session_id: "ts-example-session",
_31
}),
_31
});
_31
_31
if (!response.ok) {
_31
throw new Error(`SkillFlaw run failed: ${response.status} ${response.statusText}`);
_31
}
_31
_31
const data = await response.json();
_31
console.log(JSON.stringify(data, null, 2));
_31
}
_31
_31
runFlow().catch(console.error);

When to use the native run endpoint

Use /api/v1/run/{flow_id_or_alias} when you need:

  • the same request shape as the generated API access snippets
  • tweaks
  • explicit session_id control
  • direct compatibility with existing SkillFlaw flow examples

Option 2: use the OpenAI JavaScript client

If your application already uses the OpenAI SDK, point it to SkillFlaw's OpenAI-compatible endpoint.


_20
import OpenAI from "openai";
_20
_20
const client = new OpenAI({
_20
baseURL: "http://localhost:7860/api/v1/",
_20
defaultHeaders: {
_20
"x-api-key": process.env.SKILLFLAW_API_KEY!,
_20
},
_20
apiKey: "dummy-api-key", // required by the SDK, ignored by SkillFlaw
_20
});
_20
_20
async function runResponse() {
_20
const response = await client.responses.create({
_20
model: "YOUR_FLOW_ID_OR_ALIAS",
_20
input: "Summarize the latest deployment changes.",
_20
});
_20
_20
console.log(response.output_text);
_20
}
_20
_20
runResponse().catch(console.error);

Use this option when you want SkillFlaw to fit into an existing OpenAI-client integration layer with minimal code changes.

For the full request and response contract, see OpenAI Responses API.

Authentication

For both approaches, SkillFlaw authenticates requests with the x-api-key header.

  • create or retrieve a SkillFlaw API key
  • store it in an environment variable such as SKILLFLAW_API_KEY
  • pass it in x-api-key for each request

Which option should you choose?

Use caseRecommended approach
You want the same payload structure as the SkillFlaw UI snippets/api/v1/run/{flow_id_or_alias}
You need tweaks and explicit session_id handling/api/v1/run/{flow_id_or_alias}
Your app already depends on the OpenAI JavaScript SDK/api/v1/responses
You want the smallest possible dependency surfacedirect fetch