# Initialize Mistral client
s = Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
)

def sync_request():
    res = s.chat.complete(model="mistral-small-latest", messages=[
        {
            "content": "Who is the best French painter? Answer with only the name of the painter.",
            "role": "user",
        },
    ])
    if res is not None and res.choices:
        print("Sync request result:", res.choices[0].message.content)
        return res.choices[0].message.content

async def async_request(question):
    res = await s.chat.complete_async(model="mistral-small-latest", messages=[
        {
            "content": question,
            "role": "user",
        },
    ])
    if res is not None and res.choices:
        return res.choices[0].message.content
    return None

async def main():
    # Make a sync request
    painter = sync_request()

    # Make two async requests
    tasks = [
        async_request(f"Name the most iconic painting by {painter}. Answer in one short sentence."),
        async_request(f"Name one of {painter}'s influences. Answer in one short sentence."),
    ]
    results = await asyncio.gather(*tasks)

    # Print the results of async requests
    print("Async request 1 result:", results[0])
    print("Async request 2 result:", results[1])

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

In this example, we first make a synchronous request to get the name of a painter. We then use that information to make two asynchronous requests to get more details about the painter. The SDK is only instantiated once, and the same client object is used for both synchronous and asynchronous operations.

## Using a Different HTTP Client in Speakeasy SDKs

While HTTPX is the default HTTP client in SDKs created by Speakeasy, you can [easily switch to Requests for synchronous operations](/docs/customize-sdks/custom-http-client) if needed. For example, to use Requests in the Mistral SDK, you can set the `client` parameter when initializing the client:

```python filename="mistral_requests.py"
import os
import requests
from mistralai import Mistral, HttpClient