Blog5 min read

Use SolCard Inference with the Vercel AI SDK

Call SolCard Inference from TypeScript with the AI SDK’s OpenAI-compatible provider: the createOpenAICompatible setup, streaming usage, reasoning and costs.

Contents

To use SolCard Inference with the Vercel AI SDK, install @ai-sdk/openai-compatible, call createOpenAICompatible with baseURL: 'https://api.solcardinference.ai/v1' and your sk-si- key, then pass solcard-inference-fast as the model. That’s the whole setup. Everything about the AI SDK below comes from its own docs; we haven’t run it ourselves, but it calls the same Chat Completions endpoint as OpenCode, which is built on the same package.

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. New email sign-ups may get $1 of free credit for 30 days.
  • A TypeScript or JavaScript project that can run the AI SDK. In Python, use LangChain instead.

Install and create the provider

The AI SDK’s OpenAI-compatible provider page installs one package for the provider; the functions come from ai.

pnpm add ai @ai-sdk/openai-compatible

Put the key in an environment variable, so it stays out of your code:

export SOLCARD_INFERENCE_KEY=sk-si-...

Then create the provider once and reuse it:

import { createOpenAICompatible } from '@ai-sdk/openai-compatible';

export const solcard = createOpenAICompatible({
  name: 'solcardinference',
  baseURL: 'https://api.solcardinference.ai/v1',
  apiKey: process.env.SOLCARD_INFERENCE_KEY,
  includeUsage: true,
  supportsStructuredOutputs: true,
});

What each option does, per the AI SDK’s docs:

OptionWhat it’s for
nameThe provider name. It’s also the key you use under providerOptions.
baseURLThe prefix for every request. Ours ends in /v1.
apiKeySent as the Authorization header.
includeUsage“Include usage information in streaming responses.” Off by default.
supportsStructuredOutputs“Set to true if the provider supports structured outputs.”

Turn includeUsage on. Our Chat Completions reference says stream_options: { "include_usage": true } “adds a final usage chunk”, so streamed calls report their tokens. It also lists response_format with json_schema, which is why supportsStructuredOutputs is on. The name is one lowercase word so it matches the providerOptions key exactly, which the AI SDK’s docs say is in camelCase.

Generate and stream text

solcard('model-id') gives you a model to pass to any AI SDK call. A one-shot answer:

import { generateText } from 'ai';
import { solcard } from './solcard';

const { text } = await generateText({
  model: solcard('solcard-inference-fast'),
  prompt: 'Say hello in five words.',
  maxOutputTokens: 1024,
});

console.log(text);

Streaming, with textStream, which the AI SDK’s generating text page describes as “both a ReadableStream and an AsyncIterable”:

import { streamText } from 'ai';
import { solcard } from './solcard';

const result = streamText({
  model: solcard('solcard-inference-fast'),
  prompt: 'Explain what a race condition is.',
});

for await (const textPart of result.textStream) {
  process.stdout.write(textPart);
}

console.log(await result.usage);

Every model writes at most 32,768 tokens per request. Keep maxOutputTokens at or under that. Our models take text only: no image, audio or file input.

Reasoning and tools

Reasoning is off by default, except on solcard-inference-large, which always reasons, per our reasoning guide. On Chat Completions, reasoning_effort takes none, low, medium or high. The AI SDK lists reasoningEffort among its chat provider options, under the provider’s name:

const { text } = await generateText({
  model: solcard('solcard-inference-fast'),
  prompt: 'Find the bug in this function: ...',
  providerOptions: {
    solcardinference: { reasoningEffort: 'medium' },
  },
});

Reasoning tokens are billed as output, so expect more output tokens per turn.

Function tools work; other tool types don’t. Our tool-calling guide says all three endpoints support function tools, and other tool types return 400 unsupported_tool.

Routing per call

The model is one string, so you can route per call: solcard-inference-fast for chat, summaries and extraction, solcard-inference-large when quality matters more than cost (it always reasons). solcard-inference-base has a 262,144-token context, smaller than the other two, so don’t send it your longest prompts. Fast, Large or Base compares the three.

Check it works

Check the key and URL from a terminal first:

curl https://api.solcardinference.ai/v1/models \
  -H "Authorization: Bearer $SOLCARD_INFERENCE_KEY"

You should see solcard-inference-fast, -large and -base. Then run the generateText example above.

What it costs

You pay per token from a prepaid balance. A call on Fast that sends 2,000 tokens and gets 500 back is about $0.004, or $3.75 per 1,000 calls; on Large it’s about $10.63 per 1,000 before reasoning tokens. A chat app that resends history pays the cached rate on the repeated part, a tenth of the input price.

For an app, the per-minute limit is the number to plan around: 120 requests a minute on Starter, 300 on Pro and 600 on Max. API keys spend credits first, then the plan. How billing works has the price list and the plans.

Troubleshooting

These are the API’s codes, from our errors page. How the AI SDK words them isn’t covered here.

  • 401 invalid_api_key: the key is missing, revoked or unknown. Check SOLCARD_INFERENCE_KEY is set where the code runs.
  • 400 model_not_found: the model id doesn’t match. Use solcard-inference-fast, -large or -base.
  • 400 unsupported_content: an image or file reached the model. Text only.
  • 400 unsupported_parameter: our errors page lists n above 1, best_of, previous_response_id and store: true among these.
  • 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.

The AI SDK’s settings page says maxRetries defaults to 2. Set it to 0 if you’d rather handle retries yourself.

FAQ

Can I use the @ai-sdk/openai provider instead? This guide sticks to @ai-sdk/openai-compatible, the package on the AI SDK’s page for OpenAI-compatible providers, and Chat Completions. Our API also speaks OpenAI Responses, but we haven’t written up a setup for the other package.

What about the Anthropic provider? Our API speaks Anthropic Messages too. Anthropic SDKs take the base URL https://api.solcardinference.ai, without /v1, because they add /v1/messages themselves.

Can I send images? No. Our models take text only, and a request with an image is rejected with unsupported_content.

Are my prompts stored? No. Prompts and responses are never logged or stored, on any model. Keeps nothing follows one request through.

Can I pay without a card? Yes. Top up by sending crypto to the deposit address on the dashboard’s Top up page; a card stays out of it, and on-chain transfers are public. Pay with USDC walks through it.

Bring the prompt that got refused.

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

Pay in crypto. No KYC.