Skip to content

How to use openai-agents to call text2image API? #725

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

Open
moseshu opened this issue May 20, 2025 · 0 comments
Open

How to use openai-agents to call text2image API? #725

moseshu opened this issue May 20, 2025 · 0 comments
Labels
question Question about using the SDK

Comments

@moseshu
Copy link

moseshu commented May 20, 2025

Please read this first

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

Question

The following code uses the openai api to call the text2image function. How to convert this method to openai-agents to call it?

client = OpenAI(
    
    base_url="openai.com",
    api_key=os.environ.get("openai_key"),
)

response = client.images.generate(
    model="gpt-image-1",
    prompt="Fisheye lens, a cat's head, the picture shows the cat's facial features are distorted due to the shooting method.",
    size="1024x1024",
    response_format="url"        
)
print(response.data[0].url)
@moseshu moseshu added the question Question about using the SDK label May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about using the SDK
Projects
None yet
Development

No branches or pull requests

1 participant