text_completions_demo_async.py 452 B

123456789101112131415161718
  1. import asyncio
  2. from g4f.client import AsyncClient
  3. async def main():
  4. client = AsyncClient()
  5. response = await client.chat.completions.create(
  6. model="gpt-4o",
  7. messages=[
  8. {"role": "system", "content": "You are a helpful assistant."},
  9. {"role": "user", "content": "how does a court case get to the Supreme Court?"}
  10. ]
  11. )
  12. print(response.choices[0].message.content)
  13. asyncio.run(main())