Skip to content

ConfidentApiError: Invalid API key after successful deepeval login using AnthropicModel (Python 3.13, DeepEval 4.0.9) #2876

Description

@Maheep25

Environment

  • OS: macOS
  • Python: 3.13.9
  • DeepEval: 4.0.9
  • Judge Model: AnthropicModel("claude-sonnet-4-6")
  • Anthropic SDK: 0.116.0

Description

I'm using AnthropicModel as the evaluation model (no OpenAI).

The evaluation itself completes successfully and the metric passes. The failure occurs only during the post-test upload to Confident AI (wrap_up_test_run() / post_test_run()).

The metric passes, then the following exception is raised:

deepeval.confident.types.ConfidentApiError: Invalid API key

What I verified

  • deepeval login --api-key ... succeeds.
  • CONFIDENT_API_KEY is loaded correctly.
  • ANTHROPIC_API_KEY is loaded correctly.
  • AnthropicModel is used successfully.
  • The evaluation passes.
  • curl https://api.confident-ai.com works.
  • requests.get("https://api.confident-ai.com") works.

The issue only occurs during the upload step.

Console output

You're running DeepEval's latest Task Completion Metric!
(using claude-sonnet-4-6 (Anthropic))

est_case_0 (Passed 1 metrics)

ConfidentApiError: Invalid API key

I also intermittently see:

SSLCertVerificationError:
certificate verify failed:
unable to get local issuer certificate

although Python requests and curl both connect successfully to the same endpoint.

Code

from deepeval.models import AnthropicModel
from deepeval.metrics import TaskCompletionMetric

judge = AnthropicModel(
    model="claude-sonnet-4-6"
)

evaluate(
    test_cases=[test_case],
    metrics=[
        TaskCompletionMetric(
            threshold=0.7,
            model=judge
        )
    ]
)

Expected behavior

The evaluation should upload successfully after deepeval login.

Actual behavior

Evaluation succeeds locally, but upload fails with:

ConfidentApiError: Invalid API key

deepeval --version -> 4.0.9

python --version
Python 3.13.9

deepeval login
Successfully logged in

evals/test_TaskCompletion.py:22
evaluate(...)

deepeval.evaluate.evaluate.py

global_test_run_manager.wrap_up_test_run()

post_test_run()

ConfidentApiError: Invalid API key

Additional debugging performed

I verified the following:

  • deepeval login --api-key ... succeeds.
  • CONFIDENT_API_KEY is loaded correctly from both .env and .env.local.
  • AnthropicModel is used successfully.
  • curl https://api.confident-ai.com returns HTTP 404 (expected).
  • requests.get("https://api.confident-ai.com") returns HTTP 404.
  • Python can verify SSL certificates using requests.
  • The evaluation passes before the upload attempt.

The issue reproduces even after:

  • deepeval login succeeds
  • restarting the terminal
  • restarting pytest

I also occasionally see:

SSLCertVerificationError:
certificate verify failed

However, both curl and Python requests connect successfully to
https://api.confident-ai.com, so I'm not sure whether this is related or simply a secondary warning.

Question:

Is DeepEval 4.0.9 officially supported on Python 3.13,
or is Python 3.12 currently the recommended runtime?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions