Guides
Using Droidrun with OpenAI-like
This guide explains how to use the Droidrun framework with OpenAI-compatible APIs (such as OpenAI, Azure OpenAI, OpenRouter, LM Studio, etc.). By integrating these LLMs with Droidrun, you can automate Android devices, build intelligent agents, and experiment with advanced workflows using any OpenAI-like endpoint.
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)
Make sure you’ve set up and enabled the Droidrun Portal.
1. Set Up Your API Key
Get your API key for the provider you’ve choosen
2. 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_base
tohttps://openrouter.ai/api/v1
and use your OpenRouter API key. - LM Studio: Set
api_base
to 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=False
unless 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!