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

API Key Specification for Different Agents #201

Closed
BowenBryanWang opened this issue Mar 17, 2025 · 3 comments
Closed

API Key Specification for Different Agents #201

BowenBryanWang opened this issue Mar 17, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@BowenBryanWang
Copy link

Please read this first

  • Have you read the docs?Agents SDK docs
  • Have you searched for related issues? Others may have had similar requesrs

Describe the feature

What is the feature you're requesting? How would it work? Please provide examples and details if possible.

Hi developer,

I'm curious about how do I specify different OpenAI_API_KEYs to different agent class? The issue is that I have specific key for computer-use-preview agent class, which I wish to separate against the key used for WebSearchTool agent class.

Thank you for your help!

@BowenBryanWang BowenBryanWang added the enhancement New feature or request label Mar 17, 2025
@de-code
Copy link

de-code commented Mar 18, 2025

I believe you could just pass a model instance to the agent.

import os
from openai import AsyncOpenAI
from agents import Agent, OpenAIChatCompletionsModel


model = OpenAIChatCompletionsModel(
    model=os.getenv('OPENAI_MODEL_ID', 'gpt-4o-mini'),
    openai_client=AsyncOpenAI(
        base_url=os.getenv('OPENAI_BASE_URL', 'https://api.openai.com/v1'),
        api_key=os.environ['OPENAI_API_KEY']
    )
)

agent = Agent(
    name='Assistant',
    instructions='You are a helpful assistant',
    model=model
)

@rm-openai
Copy link
Collaborator

Yup thats right ^

@BowenBryanWang
Copy link
Author

Yes but remember to make sure that different keys must belong to the same organization, otherwise the data retention might not work, items stored in previous conversation might not be found by following agents...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants