Skip to content

Commit 566e950

Browse files
committed
support env var for anthropic keys
1 parent 4ef7d0d commit 566e950

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ export OPENAI_API_KEY=sk-something-something
1515
export OPENAI_API_KEY_PASSWORD=some-password
1616
```
1717

18+
Likewise for Claude:
19+
20+
```
21+
export ANTHROPIC_API_KEY=sk-something-something
22+
export ANTHROPIC_API_KEY_PASSWORD=some-password
23+
```
24+
1825
If a team member has already set up a Google Cloud Storage project, add the keys for that project to the same `.env` file. Otheriwse,
1926
see the "Setting up a Google Cloud instance" section for how to set up a project.
2027

@@ -71,33 +78,33 @@ export type SourceRow = {
7178
timestamp?: string; // timestamp in the video
7279
};
7380
```
81+
7482
## Provided client
7583

7684
Open `localhost:8080/` to see the example of client provided.
7785
The client is written in plain html/css/js in the `public` folder.
7886

79-
8087
## Setting up a Google Cloud instance
8188

8289
### Set up Google Cloud storage & services
8390

8491
First create a new storage bucket:
92+
8593
- Create a Google Cloud project and a Google Cloud Storage bucket
8694
- Add `GCLOUD_STORAGE_BUCKET=name-of-your-bucket` to your `.env`
8795
- Make sure this bucket has public access so that anyone can read from it (to
88-
make your reports accessible from your browser):
89-
- Turn off the "Prevent public access" protect
90-
- In the "Permissions" tab, click "Grant access." Add the principal `allUsers`
91-
and assign the role `Storage Object User`.
96+
make your reports accessible from your browser): - Turn off the "Prevent public access" protect - In the "Permissions" tab, click "Grant access." Add the principal `allUsers`
97+
and assign the role `Storage Object User`.
9298

9399
Then create a service account for this bucket:
100+
94101
- In the "IAM & Admin" view, select "Service Accounts" from the left menu, and
95102
then click "Create service account"
96103
- Give this account the "Editor" role
97104
- Create keys for this account and download them as a json file:
98-
- Save this file as `./google-credentials.json`
99-
- Encode this using by running the command `base64 -i ./google-credentials.json`
100-
- Put this in a variable `GOOGLE_CREDENTIALS_ENCODED` in your `.env`
105+
- Save this file as `./google-credentials.json`
106+
- Encode this using by running the command `base64 -i ./google-credentials.json`
107+
- Put this in a variable `GOOGLE_CREDENTIALS_ENCODED` in your `.env`
101108

102109
Your .env file should now look like this:
103110

@@ -134,13 +141,13 @@ Note: the first deploy with fail if you haven't set the .env variables as descri
134141
Your cloud instance is now ready to use!
135142

136143
To upload a new image (e.g. after a fresh git pull), deploy a new docker image to the same instance:
144+
137145
- Run `./bin/docker-build-gcloud.sh`
138146
- Open the google console and search for gloud cloud run
139147
- Find your project and the `tttc-light-js` app
140148
- Click "EDIT AND DEPLOY NEW VERSION"
141149
- Find the new docker image that you just pushed from the list of available images
142150

143-
144151
## Using docker locally (not recommended)
145152

146153
There should be no need to use docker for local development, except when working on the Dockerfile or testing something docker-related, in which case you might want to use these scripts:

src/server.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ app.post("/generate", async (req, res) => {
3333
throw new Error("Missing data");
3434
}
3535
config.data = formatData(config.data);
36+
// allow users to use our keys if they provided the password
3637
if (config.apiKey === process.env.OPENAI_API_KEY_PASSWORD) {
37-
// allow users to use our keys if they provided the password
3838
config.apiKey = process.env.OPENAI_API_KEY!;
39+
} else if (config.apiKey === process.env.ANTHROPIC_API_KEY_PASSWORD) {
40+
config.apiKey = process.env.ANTHROPIC_API_KEY!;
3941
}
42+
4043
if (!config.apiKey) {
41-
throw new Error("Missing OpenAI API key");
44+
throw new Error("Missing API key");
4245
}
4346
config.filename = config.filename || uniqueSlug(config.title);
4447
const url = getUrl(config.filename);

0 commit comments

Comments
 (0)