# OpenAIResource

- Kind: `class`
- Package: [Aspire.Hosting.OpenAI](/reference/api/csharp/aspire.hosting.openai.md)
- Version: `13.4.0`
- Namespace: `Aspire.Hosting.OpenAI`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.OpenAI/OpenAIResource.cs)
- Inherits: `Resource`
- Implements: `IExpressionValue`, `IManifestExpressionProvider`, `IResource`, `IResourceWithConnectionString`, `IValueProvider`, `IValueWithReferences`

Represents a logical OpenAI account/configuration that can host one or more [OpenAIModelResource](/reference/api/csharp/aspire.hosting.openai/openaimodelresource.md) children.

## Definition

```csharp
namespace Aspire.Hosting.OpenAI;

public sealed class OpenAIResource
    : Aspire.Hosting.ApplicationModel.Resource,
      Aspire.Hosting.ApplicationModel.IExpressionValue,
      Aspire.Hosting.ApplicationModel.IManifestExpressionProvider,
      Aspire.Hosting.ApplicationModel.IResource,
      Aspire.Hosting.ApplicationModel.IResourceWithConnectionString,
      Aspire.Hosting.ApplicationModel.IValueProvider,
      Aspire.Hosting.ApplicationModel.IValueWithReferences
{
    // ...
}
```

## Constructors

- [OpenAIResource(string, ParameterResource)](/reference/api/csharp/aspire.hosting.openai/openairesource/constructors.md#constructor-string-parameterresource) -- Creates a new [OpenAIResource](/reference/api/csharp/aspire.hosting.openai/openairesource.md).

## Properties

- [ConnectionStringExpression](/reference/api/csharp/aspire.hosting.openai/openairesource/properties.md#connectionstringexpression) : `ReferenceExpression` `get` -- Gets the base connection string for the OpenAI account.
- [Endpoint](/reference/api/csharp/aspire.hosting.openai/openairesource/properties.md#endpoint) : `string` `get` -- Gets or sets the service endpoint base URI for OpenAI-compatible services. Defaults to https://api.openai.com/v1.
- [Key](/reference/api/csharp/aspire.hosting.openai/openairesource/properties.md#key) : `ParameterResource` `get` -- Gets or sets the API key for accessing OpenAI.
- [UriExpression](/reference/api/csharp/aspire.hosting.openai/openairesource/properties.md#uriexpression) : `ReferenceExpression` `get` -- Gets the endpoint URI expression for the OpenAI account.
