Skip to content

Conversation

@Pavanmanikanta98
Copy link
Contributor

@Pavanmanikanta98 Pavanmanikanta98 commented Dec 30, 2025

Summary

Implements SambaNova Cloud provider following the same pattern as other OpenAI-compatible providers (Together, Fireworks, Alibaba).

Changes

Core Implementation

  • New Provider: SambaNovaProvider class in pydantic_ai/providers/sambanova.py
    • Inherits from Provider[AsyncOpenAI]
    • Supports environment variables: SAMBANOVA_API_KEY, SAMBANOVA_BASE_URL
    • Multi-profile support for Meta Llama, DeepSeek, Qwen, and Mistral model families
    • OpenAI-compatible API endpoint: https://api.sambanova.ai/v1

Model Support

  • Meta Llama: Meta-Llama-3.1-8B-Instruct, Meta-Llama-3.3-70B-Instruct, Llama-4-Maverick-17B-128E-Instruct
  • DeepSeek: DeepSeek-R1-0528, DeepSeek-V3-0324, DeepSeek-R1-Distill-Llama-70B
  • Qwen: Qwen3-32B
  • Mistral: Mistral-based models

Files Changed

  • pydantic_ai/providers/sambanova.py - New provider implementation
  • pydantic_ai/providers/__init__.py - Provider registration
  • pydantic_ai/models/__init__.py - Added to compatibility type aliases
  • tests/providers/test_sambanova_provider.py - Comprehensive test suite (11 tests)
  • tests/conftest.py - Test fixtures and httpx client cleanup
  • tests/test_examples.py - Environment variable setup
  • README.md - Added to provider list
  • docs/index.md - Added to provider list
  • docs/models/overview.md - Added to OpenAI-compatible providers
  • docs/models/openai.md - Full documentation section with examples
  • docs/api/providers.md - API reference

Implementation Details

Multi-Profile Pattern

The provider implements profile matching based on model name prefixes, similar to Fireworks:

prefix_to_profile = {
    'deepseek-': deepseek_model_profile,
    'meta-llama-': meta_model_profile,
    'llama-': meta_model_profile,
    'qwen': qwen_model_profile,
    'mistral': mistral_model_profile,
}

This approach matches SambaNova's actual API naming convention (direct model names without provider prefixes).

Usage Example

from pydantic_ai import Agent

# Using shorthand
agent = Agent('sambanova:Meta-Llama-3.1-8B-Instruct')

# Or explicit provider
from pydantic_ai.providers import SambaNovaProvider
provider = SambaNovaProvider(api_key='your-key')
agent = Agent(provider, model_name='DeepSeek-R1-0528')

Checklist

Fixes #3669


Note: This implementation was verified against SambaNova's actual API documentation and model catalog to ensure correct model naming conventions and profile matching.

@dsfaccini dsfaccini added the new models Support for new model(s) label Dec 30, 2025
Implements SambaNova Cloud provider with support for multiple model families including Meta Llama, DeepSeek, Qwen, and Mistral models.

- Add SambaNovaProvider class with OpenAI-compatible API
- Implement multi-profile support for different model families
- Add comprehensive test suite
- Update documentation across README, docs/index.md, and docs/models/openai.md
- Register provider in inference system

Fixes pydantic#3669

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@dsfaccini
Copy link
Collaborator

thanks for the contribution @Pavanmanikanta98 ! Douwe will take a look when he's back :)

pavan added 4 commits December 30, 2025 21:47
The documentation in docs/models/openai.md has complete usage examples.
This matches the pattern used by Fireworks, Together, and Alibaba providers.
OpenAI-compatible providers (Alibaba, Fireworks, Together, SambaNova)
don't need api_key fixtures. Only direct model providers with
tests/models/test_*.py files require them.
@DouweM DouweM added feature New feature request, or PR implementing a feature (enhancement) size: M Medium PR (101-500 weighted lines) labels Jan 6, 2026
#> The capital of France is Paris.
```

### SambaNova
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this will have to be moved if #3941 merges first.

@Pavanmanikanta98
Copy link
Contributor Author

@DouweM Updated with the correct link to the official SambaNova model catalog documentation.

@DouweM DouweM merged commit d3f6190 into pydantic:main Jan 14, 2026
30 checks passed
@DouweM
Copy link
Collaborator

DouweM commented Jan 14, 2026

@Pavanmanikanta98 Thanks Pavan!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting author revision feature New feature request, or PR implementing a feature (enhancement) new models Support for new model(s) size: M Medium PR (101-500 weighted lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add sambanova provider

3 participants