Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 1.18 KB

File metadata and controls

55 lines (41 loc) · 1.18 KB
title OpenAIAdapter
description CopilotRuntime Adapter for OpenAI.

{/* GENERATE-DOCS path=packages/runtime/src/service-adapters/openai/openai-adapter.ts class=OpenAIAdapter */}

```jsx CopilotRuntime Example const copilotKit = new CopilotRuntime(); return copilotKit.response(req, new OpenAIAdapter()); ```

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

An optional OpenAI instance to use. The model to use.

process(request: CopilotRuntimeChatCompletionRequest)