Skip to content

Commit e3837ee

Browse files
committed
Support setting a key in the json or in API_KEY env
1 parent a26df79 commit e3837ee

File tree

1 file changed

+3
-2
lines changed
  • packages/tiny-agents/src

1 file changed

+3
-2
lines changed

packages/tiny-agents/src/cli.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ async function main() {
119119
model: z.string(),
120120
provider: z.enum(PROVIDERS_OR_POLICIES).optional(),
121121
endpointUrl: z.string().optional(),
122+
apiKey: z.string().optional(),
122123
servers: z.array(ServerConfigSchema),
123124
})
124125
.refine((data) => data.provider !== undefined || data.endpointUrl !== undefined, {
@@ -139,15 +140,15 @@ async function main() {
139140
? {
140141
endpointUrl: config.endpointUrl,
141142
model: config.model,
142-
apiKey: process.env.HF_TOKEN,
143+
apiKey: config.apiKey ?? process.env.API_KEY ?? process.env.HF_TOKEN,
143144
servers: config.servers,
144145
prompt,
145146
}
146147
: {
147148
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
148149
provider: config.provider!,
149150
model: config.model,
150-
apiKey: process.env.HF_TOKEN,
151+
apiKey: config.apiKey ?? process.env.API_KEY ?? process.env.HF_TOKEN,
151152
servers: config.servers,
152153
prompt,
153154
}

0 commit comments

Comments
 (0)