# Get Started with AISIX OSS

The open-source AISIX gateway runs directly from a declarative `resources.yaml` file, without a control plane. In this quickstart, you start the gateway in one Docker container and declare the required provider key, model, and caller API key. You then verify the first request through its OpenAI-compatible API.

This setup does not require a dashboard, control plane, or separate configuration store, making it the fastest way to evaluate the gateway locally. The example uses OpenAI as the upstream provider. Your client authenticates to AISIX with a caller API key, while the gateway uses a separate provider key to authenticate to OpenAI.

The request follows this path:

When the client requests the AISIX model name `gpt-4o-mini`, the gateway authenticates the request with the caller API key and uses the stored provider key to call OpenAI. The upstream OpenAI key is never exposed to the client.

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

* Install [Docker](https://docs.docker.com/get-docker/) to run the AISIX gateway container.
* Install [cURL](https://curl.se/) to send requests to the gateway.
* Prepare an OpenAI API key for an account with access to `gpt-4o-mini` and available quota.

## Create the Resources File[​](#create-the-resources-file "Direct link to Create the Resources File")

First, create a working directory:

```
mkdir aisix-quickstart

cd aisix-quickstart
```

Provider keys, models, and caller API keys are declared together in one `resources.yaml` file. Create it:

resources.yaml

```
_format_version: "2"



provider_keys:

  - id: 06475d5a-8aea-457e-856d-55d34d7cafbb

    display_name: openai-main

    provider: openai

    adapter: openai

    api_key: ${OPENAI_API_KEY}

    api_base: https://api.openai.com/v1



models:

  - id: 9f46bd07-eaae-4c3e-a1ae-61b420c32f10

    display_name: gpt-4o-mini

    provider: openai

    model_name: gpt-4o-mini

    provider_key_id: 06475d5a-8aea-457e-856d-55d34d7cafbb



api_keys:

  - id: 85b60b85-09dc-40fc-a403-5c7c8beb4e8d

    display_name: quickstart-caller

    key_hash: ${CALLER_API_KEY_SHA256}

    allowed_models:

      - gpt-4o-mini
```

❶ `_format_version: "2"` is mandatory and must be a quoted string. It pins the file format so a future revision can never silently misread this file.

❷ `${OPENAI_API_KEY}` is resolved from the gateway's environment when the file loads, so the file itself never contains the upstream credential. A referenced variable that is unset or empty fails the load.

❸ `provider_key_id` references the provider key above by its `id`. Every entry carries an `id`, a lowercase UUID that you choose and keep when you edit the entry; see [Resource IDs](https://docs.api7.ai/ai-gateway/reference/resources-file.md#resource-ids).

❹ `key_hash` is the SHA-256 digest of the caller API key, never the plaintext. The digest comes from the `CALLER_API_KEY_SHA256` variable that you compute in the next steps, so the file holds no credential at all.

## Create the Startup Configuration[​](#create-the-startup-configuration "Direct link to Create the Startup Configuration")

Create a `config.yaml` file that points the gateway at the resources file:

config.yaml

```
resources_file: /etc/aisix/resources.yaml



proxy:

  addr: "0.0.0.0:3000"



admin:

  enabled: false
```

❶ `resources_file` selects the file as the gateway's resource source. With this setting, the gateway does not use an external configuration store, so the `etcd` section is omitted. The two are mutually exclusive.

❷ `proxy.addr` listens for gateway traffic on port `3000` across all container interfaces. The Docker command below publishes this port at `http://127.0.0.1:3000` on the host.

For the remaining startup options, see the [Startup Configuration Reference](https://docs.api7.ai/ai-gateway/reference/configuration-files.md).

## Start AISIX OSS[​](#start-aisix-oss "Direct link to Start AISIX OSS")

Export the provider credential, the caller API key with the SHA-256 digest that `resources.yaml` references, and the local gateway origin:

```
# Replace with your OpenAI API key.

export OPENAI_API_KEY="YOUR_PROVIDER_API_KEY"



# Choose a caller API key for client requests.

export CALLER_API_KEY="YOUR_CALLER_API_KEY"

export CALLER_API_KEY_SHA256="$(printf '%s' "$CALLER_API_KEY" | sha256sum | cut -d ' ' -f 1)"



# This quickstart publishes the gateway at this origin.

export AISIX_PROXY="http://127.0.0.1:3000"
```

Before starting the gateway, validate `resources.yaml` in a short-lived container. This catches interpolation, ID, and schema errors without starting a listener:

```
docker run --rm \

  -v "$(pwd):/etc/aisix:ro" \

  -e OPENAI_API_KEY \

  -e CALLER_API_KEY_SHA256 \

  --entrypoint /usr/local/bin/aisix \

  ghcr.io/api7/aisix:1.11.0 \

  validate --resources /etc/aisix/resources.yaml
```

The command should report that the file loaded three resources. Then start the gateway, mounting the working directory so later edits remain visible inside the running container:

```
docker run -d --name aisix-quickstart \

  -v "$(pwd):/etc/aisix:ro" \

  -e OPENAI_API_KEY \

  -e CALLER_API_KEY_SHA256 \

  -p 3000:3000 -p 9090:9090 \

  ghcr.io/api7/aisix:1.11.0
```

If the file cannot be read, for example because an entry lacks a valid `id` or a variable is unset, the container exits at startup, and `docker logs aisix-quickstart` reports every problem rather than stopping at the first. An entry that fails validation is instead dropped and reported while the gateway serves the rest of the file, so run `validate` first.

## Verify the Gateway[​](#verify-the-gateway "Direct link to Verify the Gateway")

Check that the proxy listener is live:

```
curl -sS "$AISIX_PROXY/livez"
```

The command should return `ok`.

List the models visible to the caller API key:

```
curl -sS "$AISIX_PROXY/v1/models" \

  -H "Authorization: Bearer ${CALLER_API_KEY}"
```

The `data` array should include `gpt-4o-mini`.

Send a chat request through the gateway:

```
curl -sS -X POST "$AISIX_PROXY/v1/chat/completions" \

  -H "Authorization: Bearer ${CALLER_API_KEY}" \

  -H "Content-Type: application/json" \

  -d '{

    "model": "gpt-4o-mini",

    "messages": [

      {"role": "user", "content": "Say hello from AISIX OSS."}

    ]

  }'
```

The response should use the OpenAI chat-completions format and contain an assistant message under `choices[0].message`.

## Update and Reload the Configuration[​](#update-and-reload-the-configuration "Direct link to Update and Reload the Configuration")

The running gateway does not watch `resources.yaml`. To apply a change without restarting the container, edit the mounted file, validate it, and then send `SIGHUP` to the gateway process.

For example, update `resources.yaml` to add a second model and allow the existing caller API key to use it:

resources.yaml

```
_format_version: "2"



provider_keys:

  - id: 06475d5a-8aea-457e-856d-55d34d7cafbb

    display_name: openai-main

    provider: openai

    adapter: openai

    api_key: ${OPENAI_API_KEY}

    api_base: https://api.openai.com/v1



models:

  - id: 9f46bd07-eaae-4c3e-a1ae-61b420c32f10

    display_name: gpt-4o-mini

    provider: openai

    model_name: gpt-4o-mini

    provider_key_id: 06475d5a-8aea-457e-856d-55d34d7cafbb

  - id: ccd6c189-04bb-44a9-bd0a-1545a04504e9

    display_name: gpt-4o

    provider: openai

    model_name: gpt-4o

    provider_key_id: 06475d5a-8aea-457e-856d-55d34d7cafbb



api_keys:

  - id: 85b60b85-09dc-40fc-a403-5c7c8beb4e8d

    display_name: quickstart-caller

    key_hash: ${CALLER_API_KEY_SHA256}

    allowed_models:

      - gpt-4o-mini

      - gpt-4o
```

Validate the edited file inside the running container:

```
docker exec aisix-quickstart \

  /usr/local/bin/aisix validate --resources /etc/aisix/resources.yaml
```

The command should report that the file loaded four resources. If validation fails, correct the reported entries before continuing.

Reload the file:

```
docker kill --signal=HUP aisix-quickstart
```

Confirm that the caller can see both models:

```
curl -sS "$AISIX_PROXY/v1/models" \

  -H "Authorization: Bearer ${CALLER_API_KEY}"
```

The `data` array should include both `gpt-4o-mini` and `gpt-4o`. For configuration states, rejected-resource details, and other resource sources, see [Configuration Propagation](https://docs.api7.ai/ai-gateway/deployment/configuration-propagation.md).

## Clean Up[​](#clean-up "Direct link to Clean Up")

Stop and remove the quickstart gateway when you are done:

```
docker rm -f aisix-quickstart
```

The `config.yaml` and `resources.yaml` files in your working directory are untouched.

## Next Steps[​](#next-steps "Direct link to Next Steps")

You have now run AISIX OSS from one declarative file and sent provider-backed requests through it. From here:

* Read [Resource Model](https://docs.api7.ai/ai-gateway/models/resource-model.md) to see how provider keys, models, and caller API keys fit together.
* Check resource files in CI with the [CLI Reference](https://docs.api7.ai/ai-gateway/reference/cli.md).
* Call the same gateway from application code with the [OpenAI SDK](https://docs.api7.ai/ai-gateway/getting-started/openai-sdk.md) or [Anthropic SDK](https://docs.api7.ai/ai-gateway/getting-started/anthropic-sdk.md) guide.
* Review [Prepare for Production](https://docs.api7.ai/ai-gateway/deployment/production.md) before deploying the gateway for production traffic.
