This package provides an integration for LlamaIndex to use OpenAI-compatible Large Language Models (LLMs). It acts as a thin wrapper, allowing LlamaIndex applications to interact with any API that mimics the OpenAI API, making it flexible for various third-party LLM providers. The current version is 0.7.1, with releases typically tied to the broader LlamaIndex ecosystem updates.
pip install llama-index-llms-openai-likeVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize and use the `OpenAILike` LLM to complete a prompt with an OpenAI-compatible API endpoint. Environment variables are used for API configuration, with fallbacks for local testing.
Upgrade other LlamaIndex packages to their explicit integration versions (e.g., `llama-index-core`, `llama-index-embeddings-openai`). Review LlamaIndex migration guides for detailed steps.
Always set `api_base` to the exact endpoint URL of your OpenAI-compatible service and provide an `api_key` string. Consult your LLM provider's documentation for correct values.
Configure `context_window`, `is_chat_model`, and `is_function_calling_model` to accurately reflect the capabilities and requirements of your specific OpenAI-compatible model for optimal performance and correct API calls.
Run `pip install llama-index-llms-openai-like` to install the package.
Verify that `api_base` is set to the *full* endpoint URL, including any necessary API version paths (e.g., `http://localhost:11434/v1`). Ensure `is_chat_model` is correctly set (`True` for chat models, `False` for completion models) and that the `model` name is recognized by your local server. Compare your Python request with a successful `curl` command if available.
If your project indirectly depends on `llama-index-llms-openai`, install it with `pip install llama-index-llms-openai`. If you're solely using the `openai-like` integration, ensure all relevant LlamaIndex components are configured to use `OpenAILike` and that there are no lingering imports or dependencies on the specific OpenAI package.