Skip to content

Commit 6aefd6a

Browse files
committed
Create the Modal proxy token before the endpoint
modal endpoint create refuses to provision an authenticated endpoint until a workspace proxy token exists, so the README's step order could not be followed as written. Move the token step ahead of endpoint creation in both the README and the setup skill, and note the --unauthenticated alternative. Fixes #251
1 parent 58c9add commit 6aefd6a

2 files changed

Lines changed: 51 additions & 43 deletions

File tree

phonellm/.claude/skills/setup/SKILL.md

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,35 @@ must log in themselves — it's a browser flow. Ask them to run:
3232

3333
There is no `modal login`; `modal setup` is the auth command.
3434

35-
## 3. PhoneLLM endpoint
35+
## 3. Proxy token
36+
37+
The bot authenticates with a workspace proxy token rather than local Modal credentials,
38+
and this has to come **before** creating the endpoint: an authenticated endpoint requires
39+
a proxy token to already exist in the workspace, so `modal endpoint create` fails without
40+
one.
41+
42+
If `MODAL_API_KEY` is already in `server/.env`, keep it. Otherwise create one:
43+
44+
```bash
45+
modal workspace proxy-tokens create --json
46+
```
47+
48+
Combine as `<token-id>.<token-secret>` (`wk-....ws-...`) and write it to `server/.env`
49+
without echoing the secret (create that file with `cp server/.env.example server/.env`
50+
first if it doesn't exist yet). The secret is shown once and cannot be retrieved later.
51+
52+
On RBAC workspaces the new token has no environment access and the endpoint will
53+
return `401 "Webhook token not found"`. Authorize it (the endpoint lives in `main`
54+
unless created elsewhere):
55+
56+
```bash
57+
modal workspace proxy-tokens allow <token-id> main
58+
```
59+
60+
## 4. PhoneLLM endpoint
3661

3762
Check for an existing endpoint: `modal endpoint list --json`, looking for a live
38-
`phonellm-alpha-1`. If present, skip to step 4.
63+
`phonellm-alpha-1`. If present, skip to step 5.
3964

4065
If absent, **ask the user before creating** (it provisions GPU infrastructure —
4166
takes ~20–30 minutes and bills their workspace):
@@ -48,40 +73,21 @@ modal endpoint create --model pipecat-ai/phonellm-alpha-1
4873
retrieve it later (`modal endpoint list` shows status only). Then poll
4974
`modal endpoint list --json` every ~30s (in the background) until status is `live`.
5075

51-
## 4. Endpoint URL
76+
## 5. Endpoint URL
5277

5378
If `MODAL_ENDPOINT_URL` is already in `server/.env`, keep it. If you just ran
5479
`endpoint create`, use the URL from its output. Otherwise **ask the user to paste it**
5580
from their create-output scrollback or the endpoint's page in the Modal dashboard
5681
(`modal dashboard`). Do not guess hostnames — the URL's label is not derivable from
5782
the endpoint name.
5883

59-
## 5. Proxy token
60-
61-
If `MODAL_API_KEY` is already in `server/.env`, keep it. Otherwise create one:
62-
63-
```bash
64-
modal workspace proxy-tokens create --json
65-
```
66-
67-
Combine as `<token-id>.<token-secret>` (`wk-....ws-...`) and write it to `server/.env`
68-
without echoing the secret. The secret is shown once and cannot be retrieved later.
69-
70-
On RBAC workspaces the new token has no environment access and the endpoint will
71-
return `401 "Webhook token not found"`. Authorize it (the endpoint lives in `main`
72-
unless created elsewhere):
73-
74-
```bash
75-
modal workspace proxy-tokens allow <token-id> main
76-
```
77-
7884
## 6. Configure .env
7985

8086
If `server/.env` doesn't exist, `cp server/.env.example server/.env`. Ensure it has:
8187

8288
- `DEEPGRAM_API_KEY`**ask the user for it** if missing; never invent keys.
83-
- `MODAL_ENDPOINT_URL` — from step 4.
84-
- `MODAL_API_KEY` — from step 5.
89+
- `MODAL_ENDPOINT_URL` — from step 5.
90+
- `MODAL_API_KEY` — from step 3.
8591

8692
## 7. Health-check the endpoint
8793

@@ -97,7 +103,7 @@ Interpret the result:
97103
Retry every ~30s (in the background). A 30B model can take several minutes. An
98104
*instant* 503 that persists well past 10 minutes suggests a wrong URL — re-verify
99105
with the user rather than retrying forever.
100-
- **401 "Webhook token not found"** — the RBAC `allow` step (5) is missing.
106+
- **401 "Webhook token not found"** — the RBAC `allow` step (3) is missing.
101107

102108
Optionally verify the exact request path the bot uses:
103109

phonellm/README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,23 @@ modal setup
2828

2929
This opens your browser to authenticate and writes your API credentials to a local Modal profile.
3030

31-
### 2. Create the endpoint
31+
### 2. Create a proxy token
32+
33+
The bot authenticates with a workspace proxy token rather than your local credentials. Create it before the endpoint — an authenticated endpoint requires a proxy token to already exist in the workspace, and `modal endpoint create` fails without one:
34+
35+
```bash
36+
modal workspace proxy-tokens create
37+
```
38+
39+
This prints a token ID (`wk-...`) and secret (`ws-...`). Save the secret now — it can't be retrieved later. Combined as `<token-id>.<token-secret>`, they form the API key the bot sends as a Bearer token.
40+
41+
On workspaces with RBAC enabled, new tokens start with no environment access, and the endpoint rejects them with `401 "Webhook token not found"`. Allow the token into the environment the endpoint will live in (`main` unless you create it elsewhere):
42+
43+
```bash
44+
modal workspace proxy-tokens allow <token-id> main
45+
```
46+
47+
### 3. Create the endpoint
3248

3349
```bash
3450
modal endpoint create --model pipecat-ai/phonellm-alpha-1
@@ -38,7 +54,9 @@ Modal provisions an [Auto Endpoint](https://modal.com/docs/guide/endpoints) —
3854

3955
> **Note:** The CLI can't retrieve the endpoint URL after the fact — `modal endpoint list` shows status but not the URL. If you lose it, find it on the endpoint's page in the [Modal dashboard](https://modal.com/) (`modal dashboard` opens it).
4056
41-
### 3. Check that it's running
57+
> **Note:** `modal endpoint create --unauthenticated` skips the token requirement, but leaves the endpoint open to anyone on the internet. The rest of this guide assumes the authenticated endpoint above.
58+
59+
### 4. Check that it's running
4260

4361
List your endpoints and their status (`provisioning``live`):
4462

@@ -56,22 +74,6 @@ A JSON response listing `pipecat-ai/phonellm-alpha-1` means the endpoint is heal
5674

5775
> **Note:** Endpoints scale to zero when idle. The first request after creation (or after a quiet period) returns 503 while the model spins up — this can take several minutes for a 30B model, and the container logs (`modal app logs`) may go quiet during kernel compilation. Keep retrying.
5876
59-
### 4. Create a proxy token
60-
61-
The bot authenticates with a workspace proxy token rather than your local credentials:
62-
63-
```bash
64-
modal workspace proxy-tokens create
65-
```
66-
67-
This prints a token ID (`wk-...`) and secret (`ws-...`). Save the secret now — it can't be retrieved later. Combined as `<token-id>.<token-secret>`, they form the API key the bot sends as a Bearer token.
68-
69-
On workspaces with RBAC enabled, new tokens start with no environment access, and the endpoint rejects them with `401 "Webhook token not found"`. Allow the token into the environment the endpoint lives in (`main` unless you created it elsewhere):
70-
71-
```bash
72-
modal workspace proxy-tokens allow <token-id> main
73-
```
74-
7577
### 5. Verify end to end (optional)
7678

7779
Test the exact request path the bot will use — proxy-token auth against the chat completions API:

0 commit comments

Comments
 (0)