Contents
To run Pydantic AI on SolCard Inference, give an OpenAIChatModel an OpenAICompatibleProvider with base_url="https://api.solcardinference.ai/v1" and your sk-si- key. Not OpenAIProvider: Pydantic AI’s docs say that one is for OpenAI itself and assumes OpenAI’s models and features. Everything about Pydantic AI below comes from its own docs; we haven’t run it ourselves.
What you need
- A SolCard Inference API key. Make one on the dashboard’s API keys page. Keys start with
sk-si-and are shown once. - Some balance or a plan. One prepaid USD balance pays for every key and model; see how billing works.
- Pydantic AI with the OpenAI extra. Its OpenAI page says OpenAI-compatible APIs need
pydantic-aiorpydantic-ai-slim[openai].
pip install "pydantic-ai-slim[openai]"
export SOLCARD_INFERENCE_KEY=sk-si-...
Point an agent at our API
The compatible APIs page says to “use OpenAICompatibleProvider with a name for the service, its base_url and, if it needs one, its api_key.” With our values:
import os
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai_compatible import OpenAICompatibleProvider
from pydantic_ai.settings import ModelSettings
provider = OpenAICompatibleProvider(
"solcard-inference",
base_url="https://api.solcardinference.ai/v1",
api_key=os.environ["SOLCARD_INFERENCE_KEY"],
)
agent = Agent(
OpenAIChatModel("solcard-inference-fast", provider=provider),
model_settings=ModelSettings(max_tokens=4096),
)
result = agent.run_sync("Say hello in five words.")
print(result.output)
Pick the provider name once and keep it. The docs say the name “is recorded as the provider_name of every response” and that “response and item IDs only go back to a provider with the same name.” Rename it later and message history recorded under the old name stops carrying those IDs.
Keep max_tokens at or under 32,768. That’s the most any of our models writes per request. Our Chat Completions reference takes max_completion_tokens and accepts max_tokens as an alias, so the profile default that sends max_completion_tokens is fine here.
Why not OpenAIProvider with a base_url
OpenAIProvider takes a base_url too, but it brings OpenAI’s assumptions with it. The compatible APIs page says it “assumes OpenAI’s models and features, and sends OpenAI’s encrypted reasoning and compaction items to the endpoint.” The providers reference adds that “Changing base_url does not change the OpenAI model profile selection,” and points other services to OpenAICompatibleProvider.
It also keeps your OpenAI key out of it. The same reference says of OpenAICompatibleProvider’s api_key: “OPENAI_API_KEY is never used, so an OpenAI key isn’t sent to another service.” If you keep an OpenAI key in your shell for other work, that’s the behavior you want.
Reasoning: use extra_body, not thinking
Pydantic AI’s unified thinking setting may do nothing here. The profiles reference says supports_thinking has “Default: False” and “When False, the unified thinking setting in ModelSettings is silently ignored.” The compatible APIs page also warns that a reasoning model “does not mean the endpoint accepts OpenAI’s reasoning_effort values.”
Ours does. Per our reasoning guide, Chat Completions takes reasoning_effort as none, low, medium or high, reasoning is off by default, and solcard-inference-large always reasons. Send the field yourself with extra_body, which the settings reference describes as “Extra body to send to the model”:
ModelSettings(max_tokens=8192, extra_body={"reasoning_effort": "medium"})
Reasoning tokens are billed as output, so expect each turn to cost more with it on.
Structured output and tools
Leave output_type on its default mode. The output page says the default Tool Output mode hands your schema to the model as an output tool, “as it’s supported by virtually all models.” Our tool-calling guide says function tools work on all three endpoints, so a typed output_type and your own @agent.tool functions ride on the same mechanism.
Native Output depends on the profile’s supports_json_schema_output, which the profiles reference defaults to False. Our Chat Completions endpoint does accept response_format with json_schema, but Tool Output needs no profile changes.
Only function tools. On Chat Completions, any other tool type returns 400 unsupported_tool, per our errors page. Our reference doesn’t mention strict on tool definitions; if strict tools ever cause trouble, the profile has an openai_supports_strict_tool_definition flag to turn them off.
Cap what one run can spend
An agent run is a loop, and every request in it is billed. The agents page says the default UsageLimits has a request_limit of 50. Set tighter limits per run:
from pydantic_ai.usage import UsageLimits
agent.run_sync(
"Summarize this changelog.",
usage_limits=UsageLimits(request_limit=8, output_tokens_limit=20_000),
)
A run of four requests, each sending about 2,500 tokens and getting 300 back, costs about $0.0155 on Fast and about $0.045 on Large, before reasoning tokens. Repeated history may bill at the cached input rate, a tenth of the input price. On a plan, the per-minute limit is 120 requests on Starter, 300 on Pro, 600 on Max. Fast, Large or Base helps pick a model per agent; solcard-inference-base has a 262,144-token context, the smallest of the three.
Or use the Anthropic route
AnthropicModel works too, with https://api.solcardinference.ai as the base URL, no /v1. Our quickstart gives that URL for Anthropic SDKs, because they add /v1/messages themselves. Pydantic AI’s Anthropic page sets the URL on an AsyncAnthropic client and passes it in; install pydantic-ai-slim[anthropic].
import os
from anthropic import AsyncAnthropic
from pydantic_ai import Agent
from pydantic_ai.models.anthropic import AnthropicModel
from pydantic_ai.providers.anthropic import AnthropicProvider
client = AsyncAnthropic(
api_key=os.environ["SOLCARD_INFERENCE_KEY"],
base_url="https://api.solcardinference.ai",
)
agent = Agent(AnthropicModel("solcard-inference-large", provider=AnthropicProvider(anthropic_client=client)))
Our Messages endpoint is the only one that takes thinking; the errors page rejects it anywhere else.
Check it works
Rule out Pydantic AI first: if this curl fails, the problem is the key or the URL.
curl https://api.solcardinference.ai/v1/models \
-H "Authorization: Bearer $SOLCARD_INFERENCE_KEY"
The list should name solcard-inference-fast, -large and -base. Then run the first example. Codes you may see, from our errors page:
- 401
invalid_api_key: the key is missing, revoked or unknown. - 400
model_not_found: use the full id, such assolcard-inference-fast. - 400
unsupported_content: an image or file reached the model; ours take text only. - 400
unsupported_parameter:nabove 1,best_of,store: true,previous_response_id, orthinkingoutside Messages. - 402
insufficient_balance: top up, then retry. - 429
rate_limitedorplan_limit_reached: too many requests a minute, or the plan’s weekly limit is used up.
FAQ
Is there a SolCard Inference provider class in Pydantic AI?
No. OpenAICompatibleProvider with our base URL is the whole integration.
Can I use OpenAIResponsesModel instead?
The providers reference says to use it “with OpenAIResponsesModel if the service implements the Responses API,” and ours does. Our Responses reference says “nothing is stored, so send the full conversation each time,” and rejects store: true and previous_response_id. Chat Completions is the simpler route.
Why does thinking='high' change nothing?
The profile’s supports_thinking defaults to False, and then the setting is ignored. Send reasoning_effort through extra_body.
Are my prompts stored? Not by us: prompts and responses are never logged or stored. Keeps nothing follows one request through.
What about the OpenAI Agents SDK or LangChain? See the Agents SDK guide and the LangChain guide. For multi-agent crews, see the CrewAI guide. To optimize prompts instead of writing them, see the DSPy guide.