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