Skip to content

openai.BadRequestError: Error code: 400 - {'error': {'message': 'Invalid request: prompt is empty or malformed.', 'type': 'invalid_request_error', 'param': None, 'code': None}} #716

Open
@aliraza108

Description

@aliraza108

from openai import OpenAI
from openai.agent import Agent

client = OpenAI(api_key="sk-...") # Use your key here

Define a simple agent (no tools used)

agent = Agent(
name="TestAgent",
instructions="Answer questions as helpfully as possible.",
)

Try running the agent with an empty string (or malformed query)

response = agent.run("")
print(response)

OUTPUT:
openai.BadRequestError: Error code: 400 - {'error': {'message': 'Invalid request: prompt is empty or malformed.', 'type': 'invalid_request_error', 'param': None, 'code': None}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions