Skip to content

Getting 401 request error with open ai service account keys #1221

@peppermint-ai-lab

Description

@peppermint-ai-lab

Initial Checks

  • I confirm that I'm using the latest version of Pydantic AI

Description

We recently created a service account key with open ai and started using it instead of user account key. However, after few minutes (~15 minutes) we see 401 errors

openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided:  You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}

We had deployed to production (cloud run in GCP) and had validated that the deployment was funcitoning. During smoke testing, after few minutes, the error occurred. We redeployed and observed similar pattern.

I am wondering if this is an issue similar to #1186

Example Code

Python, Pydantic AI & LLM client version

python - 3.12
Pydantic and llm client - 0.0.43

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions