# OpenAIResource

- Module: [Aspire.Hosting.OpenAI](/reference/api/typescript/aspire.hosting.openai.md)
- Version: `13.2.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire)

## Definition

```typescript
interface OpenAIResource
  extends IManifestExpressionProvider,
    IResource,
    IResourceWithConnectionString,
    IValueProvider,
    IValueWithReferences {
  addModel(
      name: string,
      model: string): OpenAIModelResource;
  withApiKey(apiKey: ParameterResource): OpenAIResource;
  withEndpoint(endpoint: string): OpenAIResource;
}
```

## Methods

- [addModel](/reference/api/typescript/aspire.hosting.openai/openairesource/addmodel.md) -- `method` -- Adds an OpenAI model resource.
    ```typescript
  addModel(name: string, model: string): OpenAIModelResource
  ```
- [withApiKey](/reference/api/typescript/aspire.hosting.openai/openairesource/withapikey.md) -- `method` -- Configures the API key for the OpenAI resource.
    ```typescript
  withApiKey(apiKey: ParameterResource): OpenAIResource
  ```
- [withEndpoint](/reference/api/typescript/aspire.hosting.openai/openairesource/withendpoint.md) -- `method` -- Configures the endpoint URI for the OpenAI resource.
    ```typescript
  withEndpoint(endpoint: string): OpenAIResource
  ```
