> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ardent.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAi

<Info>
  Before building an agent that uses an OpenAI model, you'll need to create an
  [OpenAI developer account](https://platform.openai.com/) and get an API key.
</Info>

## Configuration

<ParamField path="name" type="OpenAiModel">
  The name of the [OpenAI model](https://platform.openai.com/docs/models) you want your agent to use.
  By default, your agent will use `gpt-4o-mini`.
</ParamField>

<ParamField path="secret" type="string">
  The name of the secret which contains your OpenAI API key. **NOTE:** This is the *name* of the
  secret, not your actual secret key!
</ParamField>

## Creating the Model

Calling `openai()` with no arguments will use all default values:

```ts theme={null}
import { Agent, openai } from '@ardent-ai/sdk';

const agent = new Agent({
  model: openai()
});
```

Passing a single `string` argument will set the model `name`:

```ts theme={null}
import { Agent, openai } from '@ardent-ai/sdk';

const agent = new Agent({
  model: openai('gpt-4.5-preview')
});
```

Or, you can set every parameter by passing a configuration object:

```ts theme={null}
import { Agent, openai } from '@ardent-ai/sdk';

const agent = new Agent({
  model: openai({
    name: 'gpt-4.5-preview',
    secret: 'MY_CUSTOM_OPENAI_SECRET_NAME'
  })
});
```
