SkillFlaw TypeScript integration
SkillFlaw does not currently ship a repository-owned TypeScript SDK. The recommended TypeScript integration paths are:
- call the SkillFlaw HTTP API directly from
fetch,axios, or another HTTP client - 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.
- fetch
- axios
_31const baseUrl = "http://localhost:7860";_31const apiKey = process.env.SKILLFLAW_API_KEY!;_31const flowId = "YOUR_FLOW_ID";_31_31async 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_31runFlow().catch(console.error);
_21import axios from "axios";_21_21const client = axios.create({_21 baseURL: "http://localhost:7860",_21 headers: {_21 "x-api-key": process.env.SKILLFLAW_API_KEY,_21 },_21});_21_21async function runFlow() {_21 const { data } = await client.post(`/api/v1/run/YOUR_FLOW_ID`, {_21 input_value: "Hello from axios",_21 input_type: "chat",_21 output_type: "chat",_21 session_id: "axios-session",_21 });_21_21 console.log(data);_21}_21_21runFlow().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_idcontrol - 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.
_20import OpenAI from "openai";_20_20const 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_20async 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_20runResponse().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-keyfor each request
Which option should you choose?
| Use case | Recommended 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 surface | direct fetch |