Contents
To use SolCard Inference in LlamaIndex, install llama-index-llms-openai-like and create an OpenAILike with api_base="https://api.solcardinference.ai/v1", your sk-si- key, is_chat_model=True and a real context_window. The last two matter more than they look: OpenAILike doesn’t know our models, and its defaults for both are wrong for them. Everything about LlamaIndex 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.
- The OpenAILike package. Its README calls it “a thin wrapper around the OpenAI API” that “can be used with any OpenAI-compatible API.”
pip install llama-index-llms-openai-like
export SOLCARD_INFERENCE_KEY=sk-si-...
Set up OpenAILike
import os
from llama_index.core import Settings
from llama_index.llms.openai_like import OpenAILike
llm = OpenAILike(
model="solcard-inference-fast",
api_base="https://api.solcardinference.ai/v1",
api_key=os.environ["SOLCARD_INFERENCE_KEY"],
is_chat_model=True,
is_function_calling_model=True,
context_window=32_000,
max_tokens=4096,
timeout=300.0,
)
Settings.llm = llm
print(llm.complete("Say hello in five words."))
Set is_chat_model=True. The API reference says it decides “whether the model uses the chat or completion endpoint” and “Defaults to False.” Our API serves Chat Completions, OpenAI Responses and Anthropic Messages, so the chat route is the one that matches.
Set is_function_calling_model=True. It also defaults to False. Our tool-calling guide says “All three endpoints support function tools,” so the flag is accurate here, and agents need it (more below).
Set context_window on purpose. The reference says it defaults to 3900 and to “Set this to your model’s context window for the best experience.” Fast and Large take about 1M tokens and Base takes 262,144, but you don’t have to use all of it. The next section explains why the number changes your bill.
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.
Raise timeout if you use Large. The reference gives timeout a default of 60.0 seconds and max_retries a default of 3. solcard-inference-large always reasons, per our reasoning guide, and our errors page only gives up on a generation after 9 minutes (504 upstream_timeout). A client that quits at 60 seconds can cut off a long answer and then retry it from scratch.
Setting Settings.llm makes it the default for every index and query engine. The LLM guide names the default LLM as gpt-3.5-turbo, so anything you don’t point at our model goes to OpenAI.
Why context_window changes your bill
LlamaIndex packs retrieved text up to context_window, and anything that doesn’t fit becomes another call. The response synthesizer docs list compact as the default mode: it concatenates the chunks “that can fit within the context window,” “resulting in less LLM calls.” refine “makes a separate LLM call per Node/retrieved chunk.”
With the 3,900 default, a query that retrieves 6,000 tokens of text can’t fit in one call. LlamaIndex splits it across at least two, each carrying its own prompt, so you pay for more input tokens and wait for more round trips.
A larger window means fewer calls for the same text. Retrieval still decides how much text there is, so raising the window doesn’t add input on its own. Set context_window above what your queries usually retrieve and below the model’s window. The Settings page says context_window and num_output “are used during querying” and are “automatically configured using attributes from the LLM,” so setting them on OpenAILike is enough.
Token counts are estimates. The LLM guide says the default tokenizer is cl100k from tiktoken, matched to the default LLM, and that you may need to change Settings.tokenizer when you change the LLM. Leave some headroom under the window rather than setting it to the exact limit.
Here’s what one query costs that sends 6,000 tokens of retrieved text and gets 500 back, in a single call:
| Model | Per query | Per 1,000 queries |
|---|---|---|
solcard-inference-fast | about $0.0088 | about $8.75 |
solcard-inference-base | about $0.0094 | about $9.38 |
solcard-inference-large | about $0.026 | about $25.63, plus reasoning |
Reasoning tokens bill as output, and Large always reasons. Fast, Large or Base helps you pick a model.
Embeddings go somewhere else
Set Settings.embed_model yourself, or your documents go to OpenAI. The embeddings guide says: “By default, LlamaIndex uses text-embedding-ada-002 from OpenAI.” Our API covers Chat Completions, Responses and Anthropic Messages, and embeddings aren’t on that list. Pointing Settings.llm at us doesn’t change where indexing sends your text.
The same guide shows a local option:
# pip install llama-index-embeddings-huggingface
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
Settings.embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
This is the setting to check if retention matters to you. We don’t log or store prompts or responses, but that only covers the chat calls. Your documents get embedded wherever embed_model points. A local model keeps them on your machine. Seven questions covers what to ask any other service you send them to.
Agents and tools
FunctionAgent checks the flag before it calls the model. If is_function_calling_model is left at False, LlamaIndex raises “does not support function calling API”, as in issue #18463. In that thread, a maintainer’s fix sets both is_chat_model=True and is_function_calling_model=True.
With the setup above, the agent tutorial pattern applies unchanged. agent.run is async, so call it inside an async function or a notebook:
from llama_index.core.agent.workflow import FunctionAgent
def multiply(a: float, b: float) -> float:
"""Multiply two numbers and return the product."""
return a * b
agent = FunctionAgent(tools=[multiply], llm=llm, system_prompt="Use tools for arithmetic.")
response = await agent.run(user_msg="What is 12.5 times 8?")
Only function tools. Our tool-calling guide says other tool types “return 400 unsupported_tool” on Chat Completions. Each tool step is another billed request, and the 429 concurrency_limited code on our errors page applies if you run many agents in parallel.
The Responses variant
OpenAILikeResponses targets our Responses endpoint, but Chat Completions is simpler. The reference describes it as a wrapper for “an OpenAI-compatible Responses endpoint,” with max_output_tokens instead of max_tokens. Our Responses reference says “nothing is stored, so send the full conversation each time,” and rejects store: true and previous_response_id with 400 unsupported_parameter.
LlamaIndex’s own OpenAIResponses class has a track_previous_responses option. Its reference says that turning it on also sets store to true. Leave that kind of option off with our API.
Check it works
Rule out LlamaIndex 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 complete call above. 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. Our models take text only, soOpenAILikeMultiModalhas nothing to do here. - 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. Starter allows 120 requests a minute, Pro 300 and Max 600.
FAQ
Is there a SolCard Inference package for LlamaIndex?
No. OpenAILike with our api_base covers the whole setup.
Why not use the regular OpenAI class with a custom api_base?
OpenAILike takes context_window, is_chat_model and is_function_calling_model as arguments, per its reference. Those three are what a model OpenAI doesn’t know needs.
Why are my answers built from several calls?
Your retrieved text is bigger than context_window, probably the 3,900 default. Raise it.
Are my documents stored?
Not by us: prompts and responses are never logged or stored. The embedding model is a separate service, so check Settings.embed_model. Keeps nothing follows one request through ours.
What about LangChain? See the LangChain guide.