The best way to control Claude Code, Codex and more from any computer or phone
| 1 | --- |
| 2 | title: Setup |
| 3 | description: Connect alchemy to PlanetScale — account, credentials, and profiles. |
| 4 | --- |
| 5 | |
| 6 | import PackageManagers from "../../../components/PackageManagers.astro"; |
| 7 | |
| 8 | Sign up at [planetscale.com](https://planetscale.com) and create a |
| 9 | [service token](https://planetscale.com/docs/concepts/service-tokens). |
| 10 | Install `@alchemy.run/planetscale`: |
| 11 | |
| 12 | <PackageManagers add="@alchemy.run/planetscale" /> |
| 13 | |
| 14 | Then register the provider next to your cloud's: |
| 15 | |
| 16 | ```typescript |
| 17 | // alchemy.run.ts |
| 18 | import * as Planetscale from "@alchemy.run/planetscale"; |
| 19 | |
| 20 | providers: Layer.mergeAll(Cloudflare.providers(), Planetscale.providers()), |
| 21 | ``` |
| 22 | |
| 23 | Run `alchemy profile edit --add Planetscale` and pick between two local options: |
| 24 | |
| 25 | - **OAuth.** Sign in through a browser. Alchemy refreshes the token automatically. |
| 26 | - **Stored service token.** Enter the token interactively. Alchemy saves it under |
| 27 | `~/.alchemy/credentials/<profile>/planetscale-stored.json`. |
| 28 | |
| 29 | When `CI=true`, profiles are bypassed. Set `PLANETSCALE_API_TOKEN_ID`, |
| 30 | `PLANETSCALE_API_TOKEN`, and `PLANETSCALE_ORGANIZATION`; Alchemy reads them |
| 31 | directly and persists nothing. |
| 32 | |
| 33 | See [Profiles](/environments/profiles) for how credentials are stored |
| 34 | and switched. |
| 35 | |
| 36 | ## Programmatic credentials |
| 37 | |
| 38 | Skip profiles entirely by building the `Credentials` layer from a token |
| 39 | you already have in hand — useful in tests: |
| 40 | |
| 41 | ```typescript |
| 42 | Effect.provide( |
| 43 | Planetscale.fromToken({ |
| 44 | tokenId: "abcd1234", |
| 45 | token: "api-token-secret", |
| 46 | organization: "my-org", |
| 47 | }), |
| 48 | ) |
| 49 | ``` |
| 50 | |
| 51 | `tokenId` and `token` accept plain strings or `Redacted` values. |
| 52 | |
| 53 | ## API base URL |
| 54 | |
| 55 | Requests go to `https://api.planetscale.com/v1` by default. Set |
| 56 | `PLANETSCALE_API_BASE_URL` to point profile-resolved credentials at a |
| 57 | different endpoint; `fromToken` takes an `apiBaseUrl` option instead. |
| 58 | |
| 59 | ## Next steps |
| 60 | |
| 61 | - [PlanetScale overview](/planetscale) — resources and compositions. |