Use Symfony with the Gateway¶
The amazeeio/symfony-amazeeai-configure bundle adds one console command to your Symfony app. It signs you in to the Gateway by email, creates or reuses an LLM key and vector database, and writes the credentials to .env.local (or to Symfony secrets in production).
Prerequisites¶
- PHP 8.4+
- Symfony 8.0+
- An account on the application portal — create one at my.amazee.io
Install¶
1. Require the bundle¶
composer require amazeeio/symfony-amazeeai-configure
2. Register the bundle¶
If you're using Symfony Flex, the bundle registers itself automatically. Otherwise add it to config/bundles.php:
return [
// ...
AmazeeIo\AmazeeAiConfigure\AmazeeAiConfigureBundle::class => ['all' => true],
];
Configure¶
Run the configure command with your application portal account email:
php bin/console ai:amazee:configure user@example.com
# or with Symfony CLI:
symfony console ai:amazee:configure user@example.com
The command then:
- Sends a PIN to your email. Enter it when prompted.
- Looks for an existing key with the same name. The name defaults to your machine's hostname. Set your own with
-k my-app-name. - If none exists, asks you to pick a region and creates a key there.
- Saves the credentials. In
dev/testthey go to.env.local. WhenAPP_ENV=prod, the key and database password go to Symfony secrets instead, and everything else goes to.env.local.
The variable names below are set by the bundle, so use them exactly as shown. In dev, .env.local ends up with:
AMAZEEAI_LLM_KEY=sk-...
AMAZEEAI_LLM_API_URL=https://llm.[region].amazee.ai
AMAZEEAI_VDB_HOST=vectordb1.[region].amazee.ai
AMAZEEAI_VDB_PORT=5432
AMAZEEAI_VDB_NAME=db_abcd1234
AMAZEEAI_VDB_USER=user_abcd1234
AMAZEEAI_VDB_PASSWORD=...
AMAZEEAI_VDB_DSN="pgsql:host=${AMAZEEAI_VDB_HOST};port=${AMAZEEAI_VDB_PORT};dbname=${AMAZEEAI_VDB_NAME}"
Use the credentials¶
LLM requests¶
Point any OpenAI-compatible client at AMAZEEAI_LLM_API_URL/v1 with AMAZEEAI_LLM_KEY as the bearer token. For example, with Symfony's HTTP client:
$response = $httpClient->request('POST', $_ENV['AMAZEEAI_LLM_API_URL'] . '/v1/chat/completions', [
'auth_bearer' => $_ENV['AMAZEEAI_LLM_KEY'],
'json' => [
'model' => 'claude-4-5-sonnet',
'messages' => [['role' => 'user', 'content' => 'Hello']],
],
]);
See Available Models for the full model list.
Vector database¶
The AMAZEEAI_VDB_* variables connect to a managed pgvector instance provisioned with your account. Use them anywhere you'd configure a Postgres DSN — Doctrine, a vector search library, or direct PDO.
Secure credentials for production¶
AMAZEEAI_LLM_KEY and AMAZEEAI_VDB_PASSWORD are sensitive. Run the configure command with APP_ENV=prod and it stores both in Symfony secrets for you. To move existing values by hand:
php bin/console secrets:set AMAZEEAI_LLM_KEY --env=prod
php bin/console secrets:set AMAZEEAI_VDB_PASSWORD --env=prod
Then delete those two lines from .env.local. Symfony reads secrets as env vars, so you don't need to add anything to .env.
Troubleshooting¶
- PIN email not received
- Check your spam folder. The PIN expires after a short window — re-run the configure command to request a new one.
- Bundle not loading
- If Symfony Flex didn't auto-register it, add
AmazeeAiConfigureBundletoconfig/bundles.phpmanually (see step 2 above). - Wrong region in the written URL
- The command reuses any existing key with the same name, and keeps that key's region. Run it again with a new key name (
-k new-name) and pick the region you want when asked. - Auth errors on LLM requests
- Verify
AMAZEEAI_LLM_KEYis loaded in the current environment. For containerised apps, confirm the secret is injected at runtime rather than build time.