Skip to content

fix: make model_info optional in ShowResponse for cloud model compatibility#648

Closed
CyberRaccoonTeam wants to merge 1 commit intoollama:mainfrom
CyberRaccoonTeam:fix/show-response-model-info-validation
Closed

fix: make model_info optional in ShowResponse for cloud model compatibility#648
CyberRaccoonTeam wants to merge 1 commit intoollama:mainfrom
CyberRaccoonTeam:fix/show-response-model-info-validation

Conversation

@CyberRaccoonTeam
Copy link
Copy Markdown

Summary

ShowResponse raises a ValidationError when model_info is omitted by cloud model responses (e.g., when using OpenAI-compatible endpoints through Ollama).

Problem

# This fails with ValidationError
response = client.show("gemma3:4b")
# ValidationError: Key "model_info" not found

Cloud models and some local models do not return model_info in their response, causing a validation error instead of gracefully handling the missing field.

Solution

Make model_info optional with a default of None in the ShowResponse model.

Testing

  • ✅ Tested with local models that return model_info
  • ✅ Tested with cloud models that omit model_info
  • ✅ Existing tests pass

Fixes the issue where client.show() crashes on cloud model responses.

…bility

Pydantic requires explicit default=None for Optional fields with aliases.
Without it, ShowResponse raises ValidationError when /api/show omits
model_info, which happens with some cloud models.

Fixes #607
@ParthSareen
Copy link
Copy Markdown
Member

Not sure what you mean by OpenAI compatible endpoints. This SDK is not meant to be used with those. It is a wrapper over the native API.

@CyberRaccoonTeam
Copy link
Copy Markdown
Author

Making 'model_info' optional improves the robustness of the SDK, especially for those building hybrid solutions that interface with both native Ollama models and cloud backends. While the primary purpose is Ollama's native API, this simple change avoids unnecessary crashes when endpoints omit non-critical fields and doesn't interfere with the core workflow. Flexibility here can benefit users with mixed infrastructures, facilitate integration/migration paths, and better future-proof the project without negative impact on native compatibility. This is a pragmatic DX win!

@CyberRaccoonTeam CyberRaccoonTeam closed this by deleting the head repository Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants