Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use Vertex API with OpenAI sdk? #477

Open
punkpeye opened this issue Dec 5, 2024 · 0 comments
Open

how to use Vertex API with OpenAI sdk? #477

punkpeye opened this issue Dec 5, 2024 · 0 comments
Labels
api: aiplatform Issues related to the googleapis/nodejs-vertexai API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@punkpeye
Copy link

punkpeye commented Dec 5, 2024

I tried:

const client = new GoogleAuth({
  credentials: {
    client_email: config.GOOGLE_CLOUD_CLIENT_EMAIL,
    private_key: config.GOOGLE_CLOUD_PRIVATE_KEY,
  },
  scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});

const LOCATION = 'us-central1';
const PROJECT_ID = 'glama-ai';

const accessToken = await client.getAccessToken();

if (!accessToken) {
  throw new UnexpectedStateError('Failed to get access token', {
    accessToken,
  });
}

return new OpenAI({
  apiKey: accessToken,
  baseURL: `https://${LOCATION}-aiplatform.googleapis.com/v1beta1/projects/${PROJECT_ID}/locations/${LOCATION}/endpoints/openapi`,
  dangerouslyAllowBrowser: config.VITEST,
});

but I am getting:

400 status code (no body)

@punkpeye punkpeye added priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue. labels Dec 5, 2024
@product-auto-label product-auto-label bot added the api: aiplatform Issues related to the googleapis/nodejs-vertexai API. label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: aiplatform Issues related to the googleapis/nodejs-vertexai API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

1 participant