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

OpenAI: add config baseUrl for gateways #4750

Open
hotlong opened this issue May 23, 2024 · 4 comments
Open

OpenAI: add config baseUrl for gateways #4750

hotlong opened this issue May 23, 2024 · 4 comments

Comments

@hotlong
Copy link

hotlong commented May 23, 2024

Is your feature request related to a problem? Please describe.
Yes, I cannot config gateway for OpenAI : https://developers.cloudflare.com/ai-gateway/providers/openai/

Describe the solution you'd like
Add config or as an env var

Describe alternatives you've considered
none

Additional context

Cloudflare Example:

import OpenAI from 'openai';

const openai = new OpenAI({
	apiKey: 'my api key', // defaults to process.env["OPENAI_API_KEY"]
	baseURL: "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_slug}/openai"
});

try {
  const chatCompletion = await openai.chat.completions.create({
    model: "gpt-3.5-turbo-0613",
    messages: [{ role: "user", content: "What is a neuron?" }],
    max_tokens: 100,
  });

  const response = chatCompletion.choices[0].message;

  return new Response(JSON.stringify(response));
} catch (e) {
  return new Response(e);
}
@hotlong
Copy link
Author

hotlong commented May 23, 2024

https://github.com/openai/openai-node/blob/master/src/index.ts

opts.baseURL=process.env['OPENAI_BASE_URL'] ?? https://api.openai.com/v1] - Override the default base URL for the API.

@hotlong
Copy link
Author

hotlong commented May 23, 2024

Environment variables don't work; it seems like environment variables cannot be accessed when running in sandbox mode.

@emengweb
Copy link

need that too

@hotlong
Copy link
Author

hotlong commented Jun 14, 2024

should add an environment variable to control which environment variables a piece can access during its execution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants