сделай ротацию токенов. 1 токен = 20 запрос, если больше то нужно использовать другой import asyncio
from pprint import pprint
from typing import Sequence, Any, List, Optional

import aiohttp

from image_generator import base

api_token = [
    "93c85753974bc3a3ec6507c0f912fbe2",
    "73b14af1cc92da16c57eb3499b0ada17",
    "89abb61a8193acd3dbf041041782bb69",
    "c3508f3b8f5e55c0db520bd5ed566bbe",
    "80b1ca9183ea64f61adf84d93d467763",
    "2a3e4bdabcaf11829e773f4c5cd8cec7",
    "a1c04eb72856f3746aa0a041eedf9a57",
    "21b870895d6432a56b766d50f150e743",
    "25e483b87caaa602299c2bafa57b9879"
]

model_by_size = {
    'square': 'clxlyyz0i0001zus7auvc0c8o',
    'cinema': 'clxlyyz0i0001zus7auvc0c8o',
    'portrait': 'clxlyyz0i0001zus7auvc0c8o',
}

chat_model_behaviour = {
    'creative': {
        'gpt4o': 'clxluxq8u000045k2hw9c1brx',
        'gpt4-1106-preview': 'clxluxq8u000045k2hw9c1brx',
        'claude': 'clxof6c0g0000dcrmzgl6uq6f',
        'gpt4': 'clxyedbmg0000rfdj5lr7jlcd',
        'gemini': 'clxyeh8w80001cqdez4cd1uvg',
        'perplexity': 'clxyess6h0010p453whfgc3cx',
        'sonar': 'clxyf1ufw00165oec3y2as9oy',
        'gpt4o-mini':'clys7s6qk00076jvg82vje99k',
        'llama3.1':'clyyr4n6e0000q78ez9gtq9tl'
    },
    'predictable': {
        'gpt4o': 'clxluxq8u000045k2hw9c1brx',
        'gpt4-1106-preview': 'clxluxq8u000045k2hw9c1brx',
        'claude': 'clxof6c0g0000dcrmzgl6uq6f',
    },
}


async def invoke_ai(
        session: aiohttp.ClientSession,
        token: str,
        model: str,
        inputs: List[str],
        timeout: int,
        system_prompt: Optional[str] = None
) -> Any:
    url = f'https://simple-api.glif.app/{model}'
    print(token)
    headers = {
        'Authorization': f'Bearer {token}',
        'Content-Type': 'application/json',
    }

    body = {
        'inputs': inputs,
    }
    if system_prompt is not None:
        body['inputs'].append(system_prompt)

    async with session.post(
            url=url,
            headers=headers,
            json=body,
            timeout=timeout,
    ) as response:
        data = await response.json()
        print(response.text)
        return data


class AiService(base.AiService):
    def __init__(self) -> None:
        self.session = aiohttp.ClientSession()

    async def shutdown(self) -> None:
        await self.session.close()

    async def __call__(
            self,
            prompt: str,
            image_size: str = 'square',
            chat_behaviour: Optional[str] = None,
            chat_model: str = 'gpt4o',
            system_prompt: Optional[str] = None,
    ) -> Optional[Sequence[base.Image] | base.Output]:
        model = model_by_size[image_size]
        if (
                chat_behaviour is not None and
                chat_behaviour in chat_model_behaviour
        ):
            model = chat_model_behaviour[chat_behaviour][chat_model]

        data = await invoke_ai(
            self.session,
            api_token,
            model,
            [prompt],
            120,
            system_prompt
        )

        output = data['output']

        if output is None:
            return

        if chat_behaviour is not None:
            return base.Text(value=output)

        return base.Image(url=data['output']),


async def main() -> None:
    dall_e = AiService()

    await dall_e.startup()

    pprint(await dall_e('beautiful girl', 'portrait'))

    await dall_e.shutdown()


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