Skip to content
Docs/Integrations/LangChain and LlamaIndex

LangChain and LlamaIndex

Two Python frameworks for chains and retrieval. Each has an OpenAI-compatible LLM class that takes a custom base URL.

Settings

Base URL
https://uncensoredllm.xyz/v1
API key
your vk-... key
Model
uncensoredllm-1

LangChain

  1. Install langchain-openai.
  2. Create ChatOpenAI with model, base_url and api_key.
script.pyPython
from langchain_openai import ChatOpenAI llm = ChatOpenAI(model="uncensoredllm-1", base_url="https://uncensoredllm.xyz/v1", api_key="vk-...")print(llm.invoke("Say hello in five words.").content)

LangChain's own page says this class follows the official OpenAI API shape and keeps only the standard response fields. Fields that a provider adds on top are not copied into the result. When OPENAI_BASE_URL is set in the environment, it also leaves stream_usage off; pass stream_usage=True if you want token counts while streaming.

LlamaIndex

  1. Install llama-index-llms-openai-like.
  2. Create OpenAILike with the model, api_base, api_key and is_chat_model=True.
  3. Set context_window to the real value. LlamaIndex's page says the default is small.
script.pyPython
from llama_index.llms.openai_like import OpenAILike llm = OpenAILike(    model="uncensoredllm-1",    api_base="https://uncensoredllm.xyz/v1",    api_key="vk-...",    context_window=262144,    is_chat_model=True,    is_function_calling_model=True,)print(llm.complete("Say hello in five words."))

is_function_calling_model defaults to false. The model does accept tools (see tools), so set it to true if your agent code needs them.

Check that it works

Run the two-line example for your framework. A printed reply means the base URL, key and model id are all accepted.

When something does not work

  • 401 The key was not sent or is wrong. See errors.
  • 404 unknown_url Embeddings are not served here. Use another embedding provider for retrieval and keep this one for the chat model.
  • Context warnings in LlamaIndex LlamaIndex's page gives a small default for context_window (3900). Set it as above.