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
- Install
langchain-openai. - Create
ChatOpenAIwithmodel,base_urlandapi_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
- Install
llama-index-llms-openai-like. - Create
OpenAILikewith the model,api_base,api_keyandis_chat_model=True. - Set
context_windowto 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
401The key was not sent or is wrong. See errors.404 unknown_urlEmbeddings are not served here. Use another embedding provider for retrieval and keep this one for the chat model.Context warnings in LlamaIndexLlamaIndex's page gives a small default forcontext_window(3900). Set it as above.