Skip to content

devforth/adminforth-completion-adapter-openai-responses

Repository files navigation

@adminforth/completion-adapter-openai-responses

AdminForth completion adapter for the OpenAI Responses API.

This package is the fully compatible successor to @adminforth/completion-adapter-open-ai-chat-gpt.

Installation

pnpm i @adminforth/completion-adapter-openai-responses

Usage

import CompletionAdapterOpenAIResponses from "@adminforth/completion-adapter-openai-responses";

const adapter = new CompletionAdapterOpenAIResponses({
	openAiApiKey: process.env.OPENAI_API_KEY as string,
	model: "gpt-5-nano",
	extraRequestBodyParameters: {
		temperature: 0.7,
	},
});

To use the Chat Completions API instead of the Responses API, set useCompletionApi: true:

const adapter = new CompletionAdapterOpenAIResponses({
	openAiApiKey: process.env.OPENAI_API_KEY as string,
	model: "gpt-5-nano",
	useCompletionApi: true,
});

OpenAI-compatible providers can be used by overriding the base URL. The adapter still uses the Responses API by default:

const adapter = new CompletionAdapterOpenAIResponses({
	openAiApiKey: process.env.OVH_AI_ENDPOINTS_ACCESS_TOKEN as string,
	baseUrl: "https://oai.endpoints.kepler.ai.cloud.ovh.net/v1",
	model: "gpt-oss-20b",
	extraRequestBodyParameters: {
		store: false,
	},
});

If the provider only supports Chat Completions, also set useCompletionApi: true.

The adapter supports:

  • regular text completion
  • json_schema structured output
  • reasoning effort control
  • tool calls
  • streaming output chunks
  • streaming reasoning chunks
  • Responses API continuation with previousResponseId

Responses continuation

For regular completion flows you can pass the previous Responses API id to reuse server-side context. The adapter returns the current responseId, which can be used as previousResponseId on the next call:

const first = await adapter.complete({
	content: "Summarize the project requirements",
	maxTokens: 300,
});

const second = await adapter.complete({
	content: "Now turn that into three implementation milestones",
	maxTokens: 300,
	previousResponseId: first.responseId,
});

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors