--- title: Gateway quickstart description: Start the gateway on your own machine, connect a provider, send a first request and see what it cost. platforms: [docker, npm] --- # Gateway quickstart Start the gateway on your machine, send it a first request and see the request's tokens and cost, in a few minutes. :::when platform=docker ```bash git clone https://github.com/ArtificialAnalysis/Tokedex.git cd Tokedex docker compose up --no-build ``` ```text gateway-1 | Gateway is ready. Sign in with this master key: gateway-1 | gateway-1 | gateway-1 | gateway-1 | Find it as /home/node/.tokedex/master-key. Follow the Quick start on Home after signing in. ``` You need: Docker with Compose, and an API key from a model provider, such as OpenAI, Anthropic or Google. Docker pulls the published image on the first start. Keep the container logs private because they contain the master key. ::: :::when platform=npm ```bash git clone https://github.com/ArtificialAnalysis/Tokedex.git cd Tokedex npm install npm start ``` ```text ● Gateway is up Dashboard http://127.0.0.1:4000/ API http://127.0.0.1:4000/v1 Control http://127.0.0.1:4000/control Master key Saved as ~/.tokedex/master-key. Sign in with it, then follow the Quick start on Home. ``` You need a supported Node.js LTS release (see `engines` in [`package.json`](https://github.com/ArtificialAnalysis/Tokedex/blob/main/package.json)) and an API key from a model provider, such as OpenAI, Anthropic or Google. `npm start` builds the gateway and its dashboard first, which takes a few minutes. With pnpm, `pnpm install` and `pnpm start` do the same. ::: ## Sign in 1. Open `http://127.0.0.1:4000` in a browser on the same machine. 2. Paste the master key and choose **Continue with master key**. The dashboard opens on **Home**. The master key has full access, so keep it private. To sign in with a password from now on, choose **Create account** in the **Using master key** banner. Do it before you invite anyone, and keep the master key for recovery after that, so the key that can do everything stays out of daily use. ## Send your first request Follow the **Quick start** card at the top of **Home**: 1. Under **Connect a model provider**, choose your provider, paste its API key and choose **Save key**. The card says the provider is connected. 2. Under **Make your first request**, choose **Create API key**. The card's command now holds a new API key, shown this once. 3. Choose **Copy command** and run it in a terminal. ```bash curl http://127.0.0.1:4000/v1/chat/completions \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{"model":"{{models.openai}}","messages":[{"role":"user","content":"Say hello in one short sentence."}]}' ``` ```json {"id":"chatcmpl-…","object":"chat.completion","model":"{{models.openai}}","choices":[{"index":0,"message":{"role":"assistant","content":"Hello there!"},"finish_reason":"stop"}],"usage":{"prompt_tokens":14,"completion_tokens":2,"total_tokens":16}} ``` The card fills in a model that your provider serves, such as `{{models.openai}}` for OpenAI. The request calls your provider and can incur charges. ## See what it cost The Quick start card shows what the request cost. Once the request is served, the card reads **You're set up**, and **See its trace and cost** shows what the request used: ```text Your first request used 16 tokens (14 in, 2 out), costing <$0.0001. ``` ![The Quick start card on Home with all three steps completed, showing the tokens and cost of the first request](/images/dashboard/home-quick-start.png) Choose **Open its trace →** to open the request in **Observability**, with the provider and model that answered and its **Estimated cost**. If the request is refused or fails, the card says why and how to fix it. ## Check that the gateway is running ```bash curl -sS http://127.0.0.1:4000/readyz ``` ```json {"ok":true,"release":{"environment":"local"},"service":"tokedex"} ``` The check needs no key. ## State and the master key :::when platform=docker The gateway keeps its state, the master key and the provider keys you save in the `gateway-data` volume. `docker compose down` keeps the volume. To choose your own master key, set `TOKEDEX_MASTER_KEY` to at least 32 characters in a `.env` file in the repository root before the first start. To back up the volume and rehearse a restore, choose **Docker** under **Run with**. [Backup and restore](/gateway/backup-restore) > **Important:** Stop the gateway with `docker compose down`, without `-v`. Deleting the volume deletes your accounts, API keys and saved provider keys, and the gateway starts again as a new installation. ::: :::when platform=npm The gateway keeps its state and the master key in `~/.tokedex`. To back it up, stop the gateway and archive that directory with your `.env` if you made one. Keep the archive in private, encrypted storage because it contains credentials. To upgrade, take a backup, check out the new release, then run `npm install` and `npm start`. The gateway keeps using `~/.tokedex`. If the new release fails, use the backup to restore the release you ran and its state. To choose your own master key, set `TOKEDEX_MASTER_KEY` to at least 32 characters in a `.env` file in the repository root before the first start. `.env.example` lists the other settings. ::: The gateway answers only on its own machine. Before anyone else uses it, serve it over [HTTPS](/gateway/https). To run it in production, see [Deploy to production](/gateway/deploy). Next: [Connect your app](/gateway/connect-your-app), [Provider credentials](/gateway/provider-credentials) or [Observability](/gateway/requests-and-sessions).