Pydantic AI with an uncensored model

To run Pydantic AI with an uncensored model, wrap an abliterated model id in OpenAIChatModel with an OpenAICompatibleProvider that sets the base URL.

Updated November 18, 2026By unrestrictedaiagent
agent.pyPython
import os
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai_compatible import OpenAICompatibleProvider

model = OpenAIChatModel(
    "kimi-k3.1-pro-uncensored",
    provider=OpenAICompatibleProvider(
        "silkcompute",
        base_url="https://api.silkcompute.com",
        api_key=os.environ["SILK_API_KEY"],
    ),
)
agent = Agent(model, instructions="Work only on the user's own data.")

@agent.tool_plain
def count_lines(path: str) -> int:
    """Count the lines in a local file."""
    return sum(1 for _ in open(path))

print(agent.run_sync("How many lines are in data/leads.csv?").output)
OpenAI format
OpenAICompatibleProvider
Anthropic format
AsyncAnthropic(base_url=)
Tool calling
@agent.tool_plain
Streaming
agent.run_stream
Browser use
Not documented
Memory
Message history

Labels link to Pydantic AI's own docs, read November 18, 2026. Compare all 11

Point the agent only at systems, files and accounts you own or are allowed to test.

Deploy it

3 steps, with Kimi K3.1 Pro.

  1. 01

    Install the slim package. The openai extra brings the OpenAI SDK.

    Terminal
    pip install "pydantic-ai-slim[openai]"
    export SILK_API_KEY=...
  2. 02

    Name the provider. The docs say to keep the provider name stable, since it decides what history goes back.

    See agent.py above
  3. 03

    Use the Anthropic format instead. Pass your own AsyncAnthropic client to AnthropicProvider.

    agent.py
    from anthropic import AsyncAnthropic
    from pydantic_ai.models.anthropic import AnthropicModel
    from pydantic_ai.providers.anthropic import AnthropicProvider
    
    client = AsyncAnthropic(api_key=os.environ["SILK_API_KEY"],
                            base_url="https://api.silkcompute.com")
    model = AnthropicModel("kimi-k3.1-pro-uncensored",
                           provider=AnthropicProvider(anthropic_client=client))

Which model

The config uses the Silk Compute base URL, which serves both models with a 1,048,576-token context.

Sources

More frameworks