Integration guide · Evidence checked 20 November 2026

LlamaIndex with Plugsky: OpenAI-compatible LLMs and embeddings

Point LlamaIndex at Plugsky and you keep the framework's indexes, retrievers and query engines while changing the model backend. This guide covers the two classes that matter, the settings that break silently, streaming, embeddings and the errors you will actually see.

Short answer. Install llama-index-llms-openai-like and llama-index-embeddings-openai-like. Create an OpenAILike LLM with api_base="https://api.plugsky.com/v1", model="plugsky-pro", context_window=262144 and is_chat_model=True, assign it to Settings.llm, then assign an OpenAILikeEmbedding using plugsky-embed to Settings.embed_model.

Why use OpenAILike rather than the OpenAI class

LlamaIndex ships two ways to reach an OpenAI-shaped endpoint. The native OpenAI class assumes an OpenAI model name and derives metadata from it. OpenAILike is a thin wrapper that lets you declare the base URL, the model ID, the context window and whether the endpoint serves chat or legacy completions. For a third-party gateway such as Plugsky, the explicit version is safer.

The wrapper still uses the official OpenAI Python SDK underneath, so retries, timeouts and exception types behave the way the SDK documents. What changes is the base URL and the model metadata that LlamaIndex uses for prompt budgeting and chat routing.

The approved base URL for these examples is https://api.plugsky.com/v1. Plugsky's public docs also show https://plugsky.com/v1 in places; use one consistently, and confirm which host your key, firewall and SDK configuration expect before you ship.

Install the two integration packages

Install LlamaIndex with the OpenAI-like LLM and embedding packages. The core package supplies Settings, indexes and readers.

pip install llama-index \
  llama-index-llms-openai-like \
  llama-index-embeddings-openai-like

Keep the API key in an environment variable rather than in a notebook or a committed settings file. The examples read PLUGSKY_API_KEY and never print it.

Configure Settings.llm

This is the smallest configuration that works for chat and tool-capable models. Every parameter below is documented by LlamaIndex, and the values match Plugsky's published model facts.

import os
from llama_index.core import Settings
from llama_index.llms.openai_like import OpenAILike

Settings.llm = OpenAILike(
    model="plugsky-pro",
    api_base="https://api.plugsky.com/v1",
    api_key=os.environ["PLUGSKY_API_KEY"],
    context_window=262144,
    max_tokens=4096,
    is_chat_model=True,
    is_function_calling_model=True,
    timeout=120,
)

Four defaults in OpenAILike deserve attention. is_chat_model defaults to False, context_window defaults to 3,900, max_retries defaults to 3 and timeout defaults to 60 seconds. Leaving is_chat_model at its default is a common failure: LlamaIndex takes the legacy completions path instead of /v1/chat/completions.

max_tokens is the output ceiling for a request, not the model's maximum. Plugsky's plugsky-pro lists a 16,384-token maximum output, but your plan may cap output lower: Hobby 8K, Starter 16K, Builder and Scale 32K. Set the smaller of the two so a request does not fail on a plan boundary. The example uses 4,096 to stay inside every plan; raise it when you need longer outputs.

Settings that matter for an OpenAI-compatible LlamaIndex backend
SettingOpenAILike defaultSet it toWhy
api_basehttps://api.openai.com/v1https://api.plugsky.com/v1Routes requests to Plugsky instead of OpenAI.
is_chat_modelFalseTrueUses /chat/completions rather than the legacy completions path.
context_window3,900262,144 for main text modelsPrevents premature truncation; the plan input ceiling still applies.
max_tokensNoneYour plan's output ceilingMakes the output budget explicit and avoids a plan-level rejection.
is_function_calling_modelFalseTrue only for tool-capable modelsTells LlamaIndex it may pass tool schemas to the model.
timeout60 seconds120 seconds or more for long answersReduces client-side timeouts on long generations.

Configure Settings.embed_model

OpenAILikeEmbedding uses the same OpenAI embeddings shape. Plugsky's plugsky-embed family returns 2,048-dimension vectors, accepts up to 2,048 inputs per request and supports optional dimension truncation. Set a batch size that fits your rate limit and memory.

from llama_index.embeddings.openai_like import OpenAILikeEmbedding

Settings.embed_model = OpenAILikeEmbedding(
    model_name="plugsky-embed",
    api_base="https://api.plugsky.com/v1",
    api_key=os.environ["PLUGSKY_API_KEY"],
    embed_batch_size=64,
)

Keep the model and dimension count stable between indexing and querying. If you truncate dimensions for storage, query with the same truncation; a collection built at 2,048 dimensions and queried at 1,024 is a dimension mismatch, not a relevance problem.

Plugsky also exposes plugsky-embed-multilingual for cross-lingual retrieval, including Arabic. Test it on your own corpus rather than assuming that a multilingual label guarantees quality on your domain.

Build a small index and query it

With both settings in place, the ordinary LlamaIndex pipeline works unchanged. This example reads a folder of documents, embeds them with Plugsky, stores the index in memory and answers a question with the configured chat model.

from llama_index.core import SimpleDirectoryReader, VectorStoreIndex

Settings.chunk_size = 512
Settings.chunk_overlap = 50

documents = SimpleDirectoryReader("./documents").load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine(similarity_top_k=4)

response = query_engine.query("What does the contract say about termination?")
print(response)

Chunk size is a retrieval decision, not a model limit. Smaller chunks improve precision and increase the number of vectors; larger chunks preserve context and consume more prompt tokens per query. Measure recall on a labelled set before you tune it.

Streaming and async

Streaming works at the LLM level. Iterate over stream_chat and forward the delta, not the accumulated text, or the client will repeat the answer.

from llama_index.core.llms import ChatMessage

messages = [ChatMessage(role="user", content="Draft a migration checklist.")]
for chunk in Settings.llm.stream_chat(messages):
    print(chunk.delta, end="")

For an async service, use achat and astream_chat. The async stream is awaited once to obtain the generator, then consumed with async for.

response = await Settings.llm.achat(messages)
print(response)

async for chunk in await Settings.llm.astream_chat(messages):
    print(chunk.delta, end="")

Errors you will see, and what to do

Because OpenAILike wraps the OpenAI SDK, HTTP failures surface as openai.APIStatusError subclasses. Plugsky adds a machine-readable error_code, retry_after and request_id to the error body, which is more useful than the status alone.

Common failures when running LlamaIndex against Plugsky
SymptomLikely causeFix
404 on every chat callis_chat_model left at False, or the model ID is wrong.Set is_chat_model=True; confirm the ID with GET /v1/models.
401 AuthenticationErrorMissing, revoked or malformed key.Create a new key in the dashboard; check for whitespace in the environment variable.
400 context_too_largePrompt exceeds the model or plan input ceiling.Reduce retrieved chunks or history; raise the plan ceiling or choose a larger-context model.
400 invalid_tool_schemaTool schema uses JSON Schema keywords the upstream rejects.Simplify the schema; test the same tool definition with a direct chat request.
429 plan_rpm_limit or plan_concurrency_limitYour plan's request rate or in-flight limit.Honour Retry-After; add jitter; reduce parallel query engines or upgrade.
429 daily_token_capDaily allowance exhausted on Hobby or Starter.Wait for 00:00 UTC or move to Builder or Scale, which have no monthly token cap.
503 upstream_unavailableEvery routing lane failed.Retry after the advertised delay; use a smaller request if the failure repeats.

Limits to design around

  • Model context: 262,144 tokens on the main text models; 131,072 on the vision models; 8,192 on the embedding models.
  • Plan input ceilings: Hobby 64K, Starter 128K, Builder 256K and Scale a 512K plan ceiling. The model context does not override the plan.
  • Output: plan ceilings run from 8K on Hobby to 32K on Builder and Scale; the model's own maximum may be lower.
  • Concurrency and RPM: 4/120 on Hobby, 6/240 on Starter, 10/600 on Builder and 16/1,200 on Scale. Fair use applies.
  • Embeddings: 2,048 inputs per request, 2,048 dimensions by default, optional truncation, 8,192-token model context.
  • Free plan: new accounts get 100 requests and 50,000 tokens per day; older accounts retain 500 requests and 250,000 tokens per day until migration.

What we did not verify

  • We did not benchmark retrieval quality, latency or token throughput for any model. Tune chunk size and top-k on your own labelled queries.
  • We did not test every LlamaIndex release. The class parameters and defaults described here are from the current API reference checked on 20 November 2026.
  • We did not verify third-party vector store integrations. This guide uses the in-memory index; a production store needs its own dimension and distance-metric check.
  • We did not review a DPA or security report for your deployment. Request the current SOC 2 report under NDA and confirm its scope and period; SOC 2 readiness is not certification.

Frequently asked questions

Do I use OpenAI or OpenAILike for Plugsky in LlamaIndex?

Use OpenAILike from llama-index-llms-openai-like for an OpenAI-compatible endpoint such as Plugsky. It exposes api_base and model metadata explicitly, so you can set the served context window and chat mode without relying on an OpenAI model name.

Why does LlamaIndex call the wrong endpoint?

OpenAILike defaults is_chat_model to False, which routes chat through the legacy completions path. Set is_chat_model=True so LlamaIndex sends requests to /v1/chat/completions, which is the endpoint Plugsky documents.

Which embedding model should I use?

Use plugsky-embed with OpenAILikeEmbedding. It returns 2,048-dimension vectors, accepts up to 2,048 inputs per request and supports optional dimension truncation. Keep the same model and dimension count for indexing and querying.

Does LlamaIndex streaming work with Plugsky?

Yes. Set is_chat_model=True and iterate over stream_chat or astream_chat. Each chunk carries a delta string, so print or forward the delta rather than the accumulated response.

What context window should I configure?

Set context_window to the model's serving context, which is 262,144 tokens on Plugsky's main text models, then respect your plan's input ceiling. A Hobby plan caps input at 64K even when the model supports more.

How do I handle rate limits in LlamaIndex?

Catch openai.RateLimitError, read Retry-After when present, and retry with jitter. Plugsky also returns error_code values such as plan_rpm_limit and plan_concurrency_limit in the response body so you can distinguish a plan limit from upstream capacity.

Related pages

Run your LlamaIndex stack on Plugsky

One OpenAI-compatible endpoint for chat and embeddings, with 262K context on the main text models and plans from Free to Scale.

Start Free → See pricing

Sources

Framework parameters were checked against the LlamaIndex API reference on 20 November 2026. Provider limits were checked against Plugsky's docs on the same date.

Official pages used for this integration guide
SourcePage checkedChecked
LlamaIndexOpenAILike API reference20 Nov 2026
LlamaIndexOpenAILikeEmbedding API reference20 Nov 2026
LlamaIndexFramework documentation20 Nov 2026
OpenAI SDKopenai-python repository20 Nov 2026
PlugskyQuickstart and embeddings docs20 Nov 2026
PlugskyError codes20 Nov 2026

Last checked 20 November 2026. Plan prices and limits live at /pricing; the canonical model list is at /models.