import os, httpx, asyncio from functools import lru_cache _KEY = os.getenv("MYGENE_KEY"); _URL="https://mygene.info/v3/query" @lru_cache(maxsize=512) async def fetch_gene_info(sym: str): p={"q":sym,"fields":"symbol,name,summary,alias,entrezgene,location","size":1} if _KEY: p["api_key"]=_KEY async with httpx.AsyncClient(timeout=8) as c: r=await c.get(_URL,params=p); r.raise_for_status() return r.json().get("hits",[{}])[0] ``` :contentReference[oaicite:7]{index=7}