What is OpenAI-like?
“OpenAI-like” refers to any API that implements the OpenAI REST API standard. This includes:- OpenAI (api.openai.com)
- Azure OpenAI
- OpenRouter (https://openrouter.ai)
- LM Studio (local, https://lmstudio.ai)
- Other local or cloud endpoints that mimic the OpenAI API
Why Use OpenAI-like with Droidrun?
- Flexibility: Use cloud or local LLMs interchangeably.
- Wide Model Support: Access GPT-3.5, GPT-4, and many community models.
- Easy Integration: Droidrun supports OpenAI-compatible LLMs out of the box.
Prerequisites
- Python 3.10+
- An API key for your chosen provider (e.g., OpenAI, OpenRouter, Azure, or local server)
- droidrun framework installed (see Droidrun Quickstart)
1. Set Up Your API Key
Get your API key for the provider you’ve choosen2. Install the required Python packages:
3. Example: Using Droidrun with OpenAI-like LLM
Here is a minimal example of using Droidrun with an OpenAI-compatible LLM backend:Tips for Local and Alternative Endpoints
- OpenRouter: Set
api_basetohttps://openrouter.ai/api/v1and use your OpenRouter API key. - LM Studio: Set
api_baseto your local server URL (e.g.,http://localhost:1234/v1). - Azure OpenAI: Use the Azure-specific API base and deployment name as the model.
- Custom headers: Some endpoints require extra headers; see their docs.
4. Troubleshooting
- Authentication errors: Double-check your API key and endpoint.
- Model not found: Ensure the model name matches what your provider supports.
- Connection errors: If using a local server, make sure it is running and accessible.
- Vision: Most OpenAI-like endpoints do not support image input. Set
vision=Falseunless you know your model supports it.
5. Further Reading
With this setup, you can use any OpenAI-compatible LLM for Android automation and agent-based workflows using Droidrun!