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

# OpenAI compatibility

> Use OpenAI SDKs and request shapes with AGICTO API

AGICTO API supports OpenAI-compatible request formats. You can reuse existing OpenAI SDK code and switch the Base URL, API Key, and model name.

## Migration checklist

| Item           | OpenAI                           | AGICTO API                       |
| -------------- | -------------------------------- | -------------------------------- |
| Base URL       | `https://api.openai.com/v1`      | `https://api.agicto.cn/v1/`      |
| API Key        | OpenAI API Key                   | AGICTO API Key                   |
| Header         | `Authorization: Bearer $API_KEY` | `Authorization: Bearer $API_KEY` |
| Request format | OpenAI format                    | OpenAI-compatible format         |

## Chat completions

```bash theme={null}
curl https://api.agicto.cn/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "user",
        "content": "Summarize this text in three bullet points."
      }
    ]
  }'
```

Endpoint details: <a href="/api-reference/model/chat/message">Chat completions</a>

## Embeddings

```bash theme={null}
curl https://api.agicto.cn/v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "text-embedding-ada-002",
    "input": "AGICTO API supports OpenAI-compatible requests.",
    "encoding_format": "float"
  }'
```

Endpoint details: <a href="/api-reference/model/embeddings/create">Create embeddings</a>

## Images

```bash theme={null}
curl https://api.agicto.cn/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "gpt-image-1",
    "prompt": "A clean product illustration for an API dashboard",
    "size": "1024x1024"
  }'
```

Endpoint details: <a href="/api-reference/images/openai/generate">Generate images</a>

## Common issues

* If authentication fails, check `Authorization: Bearer $API_KEY`.
* If the SDK calls the wrong URL, check whether your Base URL includes `/v1`.
* If a model is unavailable, replace `model` with a model enabled for your account.
* If a request body fails to parse, check whether the endpoint expects JSON or `multipart/form-data`.
