Welcome to the Horchata API, where you can ask LLMs and get JSON in return! Our API enables you to interact with the Gemini Pro LLM—developed and trained by Google—to receive structured JSON responses that match your specified schema.
- LLM to JSON Conversion: Send queries to Gemini Pro LLM and receive structured JSON.
- Custom JSON Schemas: Tailor the JSON response format to meet your specific data needs.
- Built with FastAPI: Take advantage of a fast, scalable, and developer-friendly framework.
Ensure you have the following installed:
- Python 3.8 or higher
- pip
Clone the repository to your local machine:
git clone https://github.com/dumenac/horchata.git
cd horchata
Install the required packages:
pip install -r requirements.txt
Launch the API server using the following command:
Launch the API server using the following command:
bash
uvicorn main:app --reload
This starts the server on http://127.0.0.1:8000
, with --reload
enabling auto-reload for development ease.
-
Method: POST
-
Description: Submit a query and specify your JSON schema to receive structured responses.
-
Request Body:
json
-
{ "topic": "Your query topic", "model": { "Your JSON schema details" } }
-
Success Response:
json
-
{ "Your structured JSON response based on the specified schema" }
-
Error Response:
json
-
{ "detail": [ { "loc": ["location of the error"], "msg": "error message", "type": "error type" } ] }
Use curl
to interact with the API:
bash
curl -X 'POST' \ 'http://127.0.0.1:8000/generate' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "topic": "Magnus Carlsen", "model": { "Player information" } }'
Visit http://127.0.0.1:8000/docs
for interactive API documentation using Swagger UI.
Contributions are welcome. Please feel free to fork the repository and submit pull requests.
This project is licensed under the MIT License - see the LICENSE link for details.
Domenec Mele - Website - domenec@mele.dev
Project Link: https://github.com/dumenac/horchata