import asyncio

import httpx

API_URL = "http://172.16.2.210:3002/v1/chat/completions"
API_KEY = "freellmapi-a858c30561987b8aa2a58343c7fe48a6a52e65cadb9df6d5"

async def main():
    b64 = "/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wgALCAABAAEBAREA/8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABPxA="
    
    payload = {
        "model": "gemini-3.1-flash-lite-preview",
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "type": "text",
                        "text": "What is in this image?"
                    },
                    {
                        "type": "image_url",
                        "image_url": {
                            "url": f"data:image/jpeg;base64,{b64}"
                        }
                    }
                ]
            }
        ]
    }
    
    print("Calling FreeLLMAPI with Gemini 3.1 Flash Lite...")
    async with httpx.AsyncClient() as client:
        resp = await client.post(
            API_URL, 
            json=payload, 
            headers={"Authorization": f"Bearer {API_KEY}"},
            timeout=30
        )
        print("Status:", resp.status_code)
        try:
            print("Response:", resp.json())
        except Exception:
            print("Response:", resp.text)

if __name__ == "__main__":
    asyncio.run(main())
