Skip to content

ChatCompletionService giving out error when using hugging face router with providersΒ #2499

@JayGhiya

Description

@JayGhiya

Initial Checks

Description

Invalid response from OpenAI chat completions endpoint: 1 validation error for ChatCompletion\nservice_tier\n Input should be 'auto', 'default', 'flex', 'scale' or 'priority' [type=literal_error, input_value='on_demand', input_type=str]\n For further information visit https://errors.pydantic.dev/2.11/v/literal_error

Example Code

from pydantic_ai.models.openai import OpenAIModel
from pydantic_ai.providers.openai import OpenAIProvider


model = OpenAIModel('moonshotai/Kimi-K2-Instruct:groq', provider=OpenAIProvider(base_url="https://router.huggingface.co/v1",api_key=os.environ["HF_TOKEN"]))

Python, Pydantic AI & LLM client version

Python: python 3.13
Pydantic AI: 0.6.2

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions