Skip to content

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

Open
@moseshu

Description

@moseshu

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about using the SDKstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions