---
title: "OpenAIAdapter"
description: "CopilotRuntime Adapter for OpenAI."
---

{/* GENERATE-DOCS path=packages/backend/src/lib/openai-adapter.ts class=OpenAIAdapter */}
 
<RequestExample>
```jsx CopilotRuntime Example
const copilotKit = new CopilotRuntime();
return copilotKit.response(req, new OpenAIAdapter());
```
</RequestExample>
 
You can easily set the model to use by passing it to the constructor.
```jsx
const copilotKit = new CopilotRuntime();
return copilotKit.response(
  req,
  new OpenAIAdapter({ model: "gpt-4o" }),
);
```
 
To use your custom OpenAI instance, pass the `openai` property.
```jsx
const openai = new OpenAI({
  organization: "your-organization-id",
  apiKey: "your-api-key"
});
 
const copilotKit = new CopilotRuntime();
return copilotKit.response(
  req,
  new OpenAIAdapter({ openai }),
);
```

## Constructor

<ResponseField name="openai" type="OpenAI" >
An optional OpenAI instance to use.
</ResponseField>

<ResponseField name="model" type="string" >
The model to use.
</ResponseField>

## getResponse(forwardedProps: any)



<ResponseField name="forwardedProps" type="any" required>

</ResponseField>

