Call the Responses API from TypeScript with the openai library's responses.create.
POST /v1/responses speaks the Responses shape, so the openai library's client.responses drives it unchanged — point it at https://opendunes.com/v1 with your API key.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://opendunes.com/v1",
apiKey: process.env.OPENDUNES_API_KEY,
});
const response = await client.responses.create({
model: "openai/gpt-5.1",
instructions: "You answer Souk customers in French.",
input: "Quels sont vos horaires le vendredi ?",
});
console.log(response.output_text);
console.log(response.usage); // input and output tokens, and cost in DAconst stream = await client.responses.create({
model: "openai/gpt-5.1",
input: "Write a haiku about the Sahara.",
stream: true,
});
for await (const event of stream) {
if (event.type === "response.output_text.delta") process.stdout.write(event.delta);
}The usage, with cost in DA, rides the closing response.completed event.
The API is stateless: nothing is kept between requests, and previous_response_id is refused with a 400. Send the conversation again each turn — the earlier output items can go straight back into input:
const history: OpenAI.Responses.ResponseInput = [
{ role: "user", content: "What is the capital of Algeria?" },
];
const first = await client.responses.create({ model: "openai/gpt-5.1", input: history });
history.push(...(first.output as OpenAI.Responses.ResponseInput));
history.push({ role: "user", content: "What language is spoken there?" });
const second = await client.responses.create({ model: "openai/gpt-5.1", input: history });
console.log(second.output_text);An error comes back as a failed response in the Responses shape; the library throws an APIError with its status. See Errors.