You can easily set the model to use by passing it to the constructor.

const copilotKit = new CopilotRuntime();
return copilotKit.response(
  req,
  new OpenAIAdapter({ model: "gpt-4o" }),
);

To use your custom OpenAI instance, pass the openai property.

const openai = new OpenAI({
  organization: "your-organization-id",
  apiKey: "your-api-key"
});
 
const copilotKit = new CopilotRuntime();
return copilotKit.response(
  req,
  new OpenAIAdapter({ openai }),
);

Constructor

openai
OpenAI

An optional OpenAI instance to use.

model
string

The model to use.

process(request: CopilotRuntimeChatCompletionRequest)

request
CopilotRuntimeChatCompletionRequest
required