[Python] Receiving a 400 error when calling Azure OpenAI Python SDK Response.create

Discussão em 'Python' iniciado por Stack, Junho 4, 2025.

  1. Stack

    Stack Membro Participativo

    I'm running an Azure Responses call using the Azure Python SDK:

    from openai import AzureOpenAI
    .
    .
    .
    self.client = AzureOpenAI(
    api_key=config.get("api_key"),
    base_url= config.get("endpoint"),
    api_version= "2025-04-01-preview"
    )
    .
    .
    .

    response = self.client.responses.create(
    model="computer-use-preview", # set this to your model deployment name
    tools=parsed_tools,
    input=self.chat_history,
    truncation="auto"
    )



    And I keep getting this error:

    openai.BadRequestError: Error code: 400 - {'error': {'message': "Invalid 'response_id': 'responses'. Expected an ID that contains letters, numbers, underscores, or dashes, but this value contained additional characters.", 'type': 'invalid_request_error', 'param': 'response_id', 'code': 'invalid_value'}}


    It doesn't look like an issue with the request content, because I've tried removing parts of the request (removing parts of input to reduce token count, removing tools...) methodically as I originally thought there was something in the request. In particular, I thought it's something to do with a function I'm passing, which requires an ID. However, removing the functions passed doesn't provide anything fruitful either.

    This happens on the first request of the run, and I've not got any response_id from a previous run to add (I've been looking at the documentation in HERE which mentions the response_id.

    I've also been debugging the sdk itself, in case there's something that's done to the server response before it being passed back to me, but all looks fine there (in fact, network traffic confirms this, as I'm also proxying the network using Charles).

    I'm running out of ideas on where to look and what seems to be the problem. I've checked SO and OpenAI forum to no avail.

    Could this be something to do with the llm stuck at an older request (for which we received a response), and now it continuously needs the response_id of that request to continue?

    Thanks a lot in advance for any help/tips you can share.

    Continue reading...

Compartilhe esta Página