"text": prompt,
            **kwargs,
        }
        async with ClientSession() as session:
            print("Requesting")
            async with session.post(url, json=payload, headers=headers) as response:
                if response.status >= 500:
                    raise Exception(f"EdenAI Server: Error {response.status}")
                elif response.status >= 400:
                    raise ValueError(
                        f"EdenAI received an invalid payload: {response.text}"
                    )
                elif response.status != 200:
                    raise Exception(
                        f"EdenAI returned an unexpected response with status "
                        f"{response.status}: {response.text}"
                    )
                response_json = await response.json()
                output = self._format_output(response_json)
                if stops is not None:
                    output = enforce_stop_tokens(output, stops)
                return output