Agent-JAE/packages/ai/src/utils/oauth/venice.ts
JAE 76c500497d
Some checks are pending
CI / build-check-test (push) Waiting to run
feat: add Venice AI provider with 158 models
- Add venice.ts OAuth provider implementation
- Register Venice in BUILT_IN_OAUTH_PROVIDERS
- Add KnownProvider type entry for venice
- Map VENICE_API_KEY in env-api-keys.ts
- Set llama-3.3-70b as default Venice model in model-resolver.ts
- Add full Venice model catalog (158 models) to models.generated.ts
- Bump jae-tui and jae-agent-core to 0.62.1
2026-03-25 16:01:41 +00:00

54 lines
1.6 KiB
TypeScript

import type { OAuthCredentials, OAuthLoginCallbacks, OAuthProviderInterface } from "./types.js";
/**
* Venice AI API key provider.
*
* Venice uses API key authentication rather than OAuth, but implements
* OAuthProviderInterface so it integrates cleanly with JAE's /login flow.
*
* Get your API key at: https://venice.ai/settings/api
*/
export async function loginVenice(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials> {
callbacks.onProgress?.("To get an API key, visit https://venice.ai/settings/api");
const apiKey = await callbacks.onPrompt({
message: "Enter your Venice AI API key:",
placeholder: "e.g. your_venice_api_key",
});
if (!apiKey || !apiKey.trim()) {
throw new Error("No API key provided");
}
return {
access: apiKey.trim(),
refresh: "",
// API keys don't expire — set a 10-year window so the refresh path is never hit
expires: Date.now() + 1000 * 60 * 60 * 24 * 365 * 10,
};
}
export async function refreshVeniceToken(credentials: OAuthCredentials): Promise<OAuthCredentials> {
// API keys don't expire, just bump the expiry forward
return {
...credentials,
expires: Date.now() + 1000 * 60 * 60 * 24 * 365 * 10,
};
}
export const veniceOAuthProvider: OAuthProviderInterface = {
id: "venice",
name: "Venice AI (API Key)",
async login(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials> {
return loginVenice(callbacks);
},
async refreshToken(credentials: OAuthCredentials): Promise<OAuthCredentials> {
return refreshVeniceToken(credentials);
},
getApiKey(credentials: OAuthCredentials): string {
return credentials.access;
},
};