# dokploy_ai (Resource)

An AI provider configuration (Settings > AI): an OpenAI-compatible endpoint that Dokploy's AI features call, for example to suggest a compose file or to analyze a deployment log.

~> **Dokploy stores and returns `api_key` in cleartext.** The attribute is sensitive, so Terraform does not print it, but anyone with API access to the server can read it. The `api_key_wo` companion keeps it out of the Terraform state.

~> Dokploy does not test the endpoint on create or update. A wrong URL, key, or model applies successfully and fails on the first AI request.

## Example Usage

```terraform
# An OpenAI-compatible endpoint for Dokploy's AI features (Settings > AI).
resource "dokploy_ai" "openai" {
  name    = "openai"
  api_url = "https://api.openai.com/v1"
  model   = "gpt-4o-mini"

  # Write-only: Terraform 1.11 or later. Change the version to send a new key.
  api_key_wo         = var.openai_api_key
  api_key_wo_version = 1
}

# A self-hosted model, kept but switched off.
resource "dokploy_ai" "local" {
  name       = "ollama"
  api_url    = "http://ollama.internal:11434/v1"
  model      = "llama3"
  api_key    = "ollama"
  is_enabled = false
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `api_url` (String) Base URL of the OpenAI-compatible API, for example `https://api.openai.com/v1`.
- `model` (String) Model name that Dokploy sends in each request, for example `gpt-4o-mini`.
- `name` (String) Display name. Dokploy does not enforce a unique name.

### Optional

> **NOTE**: [Write-only arguments](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments) are supported in Terraform 1.11 and later.

- `api_key` (String, Sensitive) API key for the provider. Set this attribute or `api_key_wo`.
- `api_key_wo` (String, Sensitive, [Write-only](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments)) Write-only form of `api_key`. Terraform keeps it out of the plan and the state. It needs Terraform 1.11 or later. Set exactly one of `api_key` and `api_key_wo`. A new value reaches the server only when `api_key_wo_version` changes.
- `api_key_wo_version` (Number) Version of `api_key_wo`. Change it to send the current `api_key_wo` value to the server. It needs `api_key_wo`.
- `is_enabled` (Boolean) Whether Dokploy uses this configuration. Defaults to `true`.

### Read-Only

- `created_at` (String) Creation timestamp from the server.
- `id` (String) AI configuration id.
- `organization_id` (String) Id of the organization that owns the configuration.

## Import

Import is supported using the following syntax:

The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:

```shell
terraform import dokploy_ai.openai uNiDiVmkdS0McHxXPUjCt
```