App template
New API
An OpenAI-compatible model gateway with PostgreSQL and an owner account ready.
- Memory when idle
- about 100 MiB
- CI measures it once the app is ready and before any traffic. Leave room for more.
- Tested on
- x86 servers
Introduction
New API is a gateway for AI models. It gives your apps one OpenAI-compatible API and sends each request to the model provider you set up.
This template runs one New API behind your domain, with its own PostgreSQL database. The first-time setup is done for you, so no setup page appears, and an administrator account named admin exists.
Values you provide
You don’t fill in anything when you deploy.
Made for you
These values are generated at deploy and kept in a Kubernetes Secret, shown as Secret/key.
- newapi-secrets/admin-password
- newapi-secrets/session-secret
- newapi-secrets/crypto-secret
Getting started
-
In Zeabur OSS, open the
new-apiservice. When Overview shows its replica as ready, the service is up. Its domain is on the Networking tab under Public domains. It is the domain you entered in the install form, for examplenewapi.example.com. -
Sign in as
admin. The password isAa1-followed by the value of keyadmin-password. Get the value from thenew-apiservice: open Variables, clicknewapi-secretsunder From config files and secrets, and click the eye icon next toadmin-password. AddAa1-in front of it. Without Zeabur OSS, this kubectl command prints the whole password:echo "Aa1-$(kubectl -n <namespace> get secret newapi-secrets -o jsonpath='{.data.admin-password}' | base64 -d)" -
Add your model providers as channels. See Configuration.
-
Secret
newapi-secretsalso holds two keys that you do not need for daily use.session-secretis the session secret, andcrypto-secretis the HMAC secret for cache keys. Show them the same way on Variables. Without Zeabur OSS, use kubectl:kubectl -n <namespace> get secret newapi-secrets -o jsonpath='{.data.session-secret}' | base64 -d kubectl -n <namespace> get secret newapi-secrets -o jsonpath='{.data.crypto-secret}' | base64 -d
Configuration
Add a model provider
A channel is one connection to a model provider. Sign in as admin, open Channels in the left sidebar, and select Add Channel. Choose the provider type, enter a name and the provider’s API key, and choose the models the channel supports. Use Test on the channel to check that it works. See Channel Management in the New API docs.
Call the gateway from an app
Create an API token in the console. See API Tokens. Then point your app at https://<your domain>/v1 and send the token as a Bearer token:
curl https://newapi.example.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-<token>" \
-d '{"model":"<model>","messages":[{"role":"user","content":"Hello"}]}'
See Using API and Playground in the New API docs.
Change the admin password
New API reads admin-password only at the first start, when it creates the administrator. A later change to the Secret does not change the password. Change it in New API after you sign in.
Back up the data
New API keeps everything it saves in the newapi-db database. The template writes only log files to /data, on scratch space that Kubernetes deletes when the replica is replaced, so there is no volume to back up. In the project, open the newapi-db database. Under Backups, set up S3 backups. To get a file instead, click More → Export. See Create, back up, and restore databases and Download a database dump in the Zeabur OSS docs.
Troubleshooting
The page shows 502 or does not load
Open the new-api service in Zeabur OSS. Check that Overview shows its replica as ready, then read the Logs tab. If the replica is not ready, open Deployments and switch to Events. If Events show OOMKilled, the service ran out of memory. Raise Maximum memory under Settings → Compute. If the domain or the certificate stays pending, see Troubleshooting on the domains page.
See Adjust replicas, resources, and health checks and View logs, events, and usage, and open a terminal in the Zeabur OSS docs.
Sign-in fails with the generated password
The password is not the Secret value alone. It starts with Aa1-. Use the command in Getting started to print it.
A request fails with a provider error
New API passes the provider’s error on. Open Channels as admin and check three things. The model name in your request must be one the channel lists, and it must exist at the provider. The API key of the channel must be valid, so select Test on the channel. The provider’s rate limit or quota must not be used up. Then open the Logs tab of the new-api service in Zeabur OSS and read the error. See Channel Management in the New API docs.
Resources
Each service is guaranteed the first amount and can use up to the second.
new-api
Ports
3000
CPU
0.1 cores to 2 cores
Memory
256 MiB to 1 GiB
newapi-db
Ports
5432
CPU
0.1 cores to 1 core
Memory
256 MiB to 1 GiB
Technical details
This release
- Version
- v1.0.0-rc.46
- Licence
- AGPL-3.0-only AND PostgreSQL AND Apache-2.0
- Homepage
- github.com
- Source file
- templates/new-api/template.yaml @ v0.6.3
Tested in CI
CI installs these exact files on a new cluster, waits until they are ready, then records the idle memory.
| Distribution | Platform | Kubernetes | Passed | Idle memory |
|---|---|---|---|---|
| kind | linux/amd64 | v1.37.0 | 102 MiB |
Security
Everything runs in its own namespace. Images are pinned by digest and workloads run as non-root users. Network access is kept to the minimum. There are no default passwords.
Known risks
Risk
If the public site is not set up yet, the first visitor could take over the administrator account.
How it is handled
A PostStart hook calls the supported /api/setup endpoint with a generated password before the Pod is ready to receive traffic. The setup creates no known root credential.
Risk
The gateway handles provider API keys, accounts and billing data. The providers you configure can send sensitive prompts to outside services.
How it is handled
Limit who can be an administrator and who can define providers. The app runs as non-root with a read-only filesystem and no Kubernetes token. Session and encryption secrets are generated, and PostgreSQL uses verified TLS. Check the AGPL obligation to offer your source code if you let others use a modified version over the network.
Risk
The database pods (CloudNativePG) need a token to call the Kubernetes API.
How it is handled
Only the database pods created by the operator get a token. The New API Pod has token mounting turned off.
What the cluster needs
Zeabur OSS suggests the components a cluster is missing. Without it, install them first.