import httpcore import json import asyncio import ssl from urllib.parse import urlparse async def embeddings_run_httpcore(input_text, url="https://sanbo1200-jina-embeddings-v3.hf.space/api/v1/embeddings"): ssl_context = ssl.create_default_context() async with httpcore.AsyncConnectionPool(ssl_context=ssl_context) as http: data = { "input": input_text, "model": "jinaai/jina-embeddings-v3" } response = await http.request( method=b"POST", url=url.encode(), headers=[ (b"content-type", b"application/json"), (b"accept", b"application/json"), ], content=json.dumps(data).encode() ) if response.status == 200: return json.loads(response.content) else: raise Exception(f"Request failed with status {response.status}") async def main(): try: result = await embeddings_run_httpcore("Your text string goes here") print(f"---{result}") except Exception as e: print(f"Error: {e}") if __name__ == "__main__": asyncio.run(main())