Blog6 min read

Use SolCard Inference with the OpenAI Agents SDK

Run OpenAI Agents SDK agents on SolCard Inference: the custom client, why to use Chat Completions, turning tracing off, and which SDK features to skip.

Contents

To run the OpenAI Agents SDK on SolCard Inference, wrap an AsyncOpenAI client pointed at https://api.solcardinference.ai/v1 in an OpenAIChatCompletionsModel, give it to your agent, and turn tracing off. The last step matters most. The SDK’s tracing is on by default and uploads each model call’s inputs and outputs to OpenAI. Everything about the SDK 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.
  • Python with the SDK: pip install openai-agents, per the SDK’s front page.
pip install openai-agents
export SOLCARD_INFERENCE_KEY=sk-si-...

Point one agent at our API

The SDK’s models page gives this pattern for any OpenAI-compatible provider. Here it is with our URL and model:

import os
from agents import (
    Agent,
    AsyncOpenAI,
    ModelSettings,
    OpenAIChatCompletionsModel,
    Runner,
    set_tracing_disabled,
)

set_tracing_disabled(True)

client = AsyncOpenAI(
    base_url="https://api.solcardinference.ai/v1",
    api_key=os.environ["SOLCARD_INFERENCE_KEY"],
)

agent = Agent(
    name="Assistant",
    instructions="You are a concise assistant.",
    model=OpenAIChatCompletionsModel(
        model="solcard-inference-fast",
        openai_client=client,
    ),
    model_settings=ModelSettings(max_tokens=4096),
)

result = Runner.run_sync(agent, "Say hello in five words.")
print(result.final_output)

Keep max_tokens at or under 32,768. That’s the most any of our models writes per request, per our Chat Completions reference.

Why Chat Completions, not Responses

The SDK defaults to OpenAI’s Responses API, and its default store behavior collides with ours. The ModelSettings reference says store is “automatically enabled when not specified” on the Responses API. On Chat Completions it’s “omitted for other providers so their own default applies.”

Our Responses reference says “Responses are stateless: nothing is stored,” and our errors page lists store: true and previous_response_id as 400 unsupported_parameter. So OpenAIChatCompletionsModel is the simpler route. If you do want Responses, set ModelSettings(store=False) and don’t pass previous_response_id to Runner.run.

Turn tracing off

Tracing is the one default here that sends your data somewhere other than us. The SDK’s tracing page says “Tracing is enabled by default,” that generation spans store “the inputs/outputs of the LLM generation,” and that the SDK “exports the spans and traces to the OpenAI backend in batches.” trace_include_sensitive_data defaults to True.

Our side keeps nothing: prompts and responses are never logged or stored. Keeps nothing follows one request through. That only helps if the SDK isn’t copying the same prompts to a trace store. Three ways to turn it off, all from the SDK’s docs:

from agents import set_tracing_disabled
set_tracing_disabled(True)          # whole process
export OPENAI_AGENTS_DISABLE_TRACING=1   # whole process, from the shell
from agents import RunConfig
Runner.run_sync(agent, "...", run_config=RunConfig(tracing_disabled=True))  # one run

The models page also says that without an OpenAI key, trace uploads fail with a 401, because “traces are uploaded to OpenAI servers.” If you see that 401 and our key is fine, tracing is the cause.

Or set our API as the default for every agent

If every agent should use our models, set the client once. The config page has set_default_openai_client and set_default_openai_api("chat_completions"). It also says to “pass use_for_tracing=False when setting the default key or client, then configure tracing separately.”

import os
from agents import Agent, AsyncOpenAI, set_default_openai_api, set_default_openai_client, set_tracing_disabled

client = AsyncOpenAI(base_url="https://api.solcardinference.ai/v1", api_key=os.environ["SOLCARD_INFERENCE_KEY"])
set_default_openai_client(client, use_for_tracing=False)
set_default_openai_api("chat_completions")
set_tracing_disabled(True)

agent = Agent(name="Assistant", instructions="...", model="solcard-inference-fast")

What works and what doesn’t

Function tools work; hosted tools don’t. Our tool-calling guide says all three endpoints support function tools. The SDK’s tools page says its built-in tools come “when using the OpenAIResponsesModel”. On our Chat Completions endpoint, any tool type other than function returns 400 unsupported_tool, so leave WebSearchTool, FileSearchTool and the code interpreter off your agents.

Structured output works. The SDK’s agents page says an output_type makes the model “use structured outputs instead of regular plain text responses.” Our Chat Completions reference accepts response_format with json_schema. The SDK’s models page warns that some providers only allow json_object; ours lists both.

Streaming usage needs one flag. ModelSettings(include_usage=True) is, per the reference, “Only available for Chat Completions API.” Our API “adds a final usage chunk” when asked, so streamed runs report their tokens.

Reasoning is off by default, except on solcard-inference-large, which always reasons. Our Chat Completions field is reasoning_effort (none, low, medium or high). The SDK’s extra_args setting passes keyword arguments “directly to the underlying model provider’s API”:

ModelSettings(extra_args={"reasoning_effort": "medium"})

Text only. Our models take no image, audio or file input, and a request with one fails with 400 unsupported_content.

Mixing models across agents

Each agent takes its own model, so split the work by cost. The models page says Agent.model is set per agent. A triage agent on solcard-inference-fast can hand the hard cases to an agent on solcard-inference-large. solcard-inference-base has a 262,144-token context, smaller than the other two, so keep long histories off it. Fast, Large or Base compares the three.

An agent run is several calls, and you pay for each. A run with five model calls, each sending about 3,000 tokens and getting 300 back, costs about $0.0225 on Fast and about $0.066 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 what a busy agent hits first: 120 requests on Starter, 300 on Pro, 600 on Max.

Check it works

Rule out the SDK 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. The SDK’s config page has enable_verbose_stdout_logging() if you need to see what it sends.

Common errors, from our errors page:

  • 401 invalid_api_key: the key is missing, revoked or unknown. A 401 from trace uploads is a different thing; see above.
  • 400 unsupported_parameter: usually store: true or previous_response_id from the Responses route.
  • 400 unsupported_tool: a hosted tool reached Chat Completions.
  • 402 insufficient_balance: top up, then retry.
  • 429 rate_limited or plan_limit_reached: too many requests a minute, or the plan’s 5-hour or weekly limit is used up.

FAQ

Do I need an OpenAI API key? No. Our key goes in the AsyncOpenAI client. With tracing off, nothing needs an OpenAI key.

Can I use the SDK’s web search tool? No, it’s an OpenAI hosted tool. Our own web search runs on Chat Completions through web_search_options, per our web search guide, at $0.008 per search. The SDK doesn’t document a setting for it, so we haven’t written one up.

Does conversation state live on your server? No. Our Responses reference says “nothing is stored, so send the full conversation each time.” Don’t pass previous_response_id.

Is there a TypeScript version? This guide covers Python. For TypeScript, the Vercel AI SDK guide uses the same endpoint.

Are my prompts stored? Not by us: prompts and responses are never logged or stored. Turn tracing off so the SDK doesn’t send them to OpenAI either.

Bring the prompt that got refused.

Private. No refusals. In the app, or in the tools you already use.

Pay in crypto. No KYC.