> For the complete documentation index, see [llms.txt](https://nerdguyahmad.gitbook.io/randomstuff/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nerdguyahmad.gitbook.io/randomstuff/clients/asyncclient.md).

# AsyncClient

Same as [`Client`](/randomstuff/clients/client.md) but this is completely async class. This class is suitable for async programs like discord bots etc.

{% hint style="info" %}
All the parameters, attributes and methods are same as [`Client`](/randomstuff/clients/client.md) except all methods are coroutine and need to be awaited. For example:

`await AsyncClient.get_ai_response('Hi')`
{% endhint %}

## Simple example

Just to assure, This is a simple example for you using this class.

```python
import randomstuff
import asyncio

client = randomstuff.AsyncClient(api_key="api-key")

async def coro():
    ai = await client.get_ai_response("hi")
    image = await client.get_image("any")
    joke = await client.get_joke("any")
    weather = await client.get_weather("new york")
    await client.close()
    print("AI: ", ai.message)
    print("Joke: ", joke.joke)
    print("Image: ", image)
    print("Temprature in NY: ", weather.current.temperature)

loop = asyncio.get_event_loop()
loop.run_until_complete(coro())    
```
