[{"data":1,"prerenderedAt":1647},["ShallowReactive",2],{"navigation":3,"/sdk/python":144,"/sdk/python-surround":1642},[4,9,14,28,38,104,122,140],{"title":5,"path":6,"stem":7,"icon":8},"Introduction","/","01.index","i-lucide-house",{"title":10,"path":11,"stem":12,"icon":13},"Quickstart","/quickstart","02.quickstart","i-lucide-rocket",{"title":15,"icon":13,"path":16,"stem":17,"children":18,"page":27},"Get started","/get-started","03.get-started",[19,23],{"title":20,"path":21,"stem":22},"API keys","/get-started/api-keys","03.get-started/01.api-keys",{"title":24,"path":25,"stem":26},"Identifiers","/get-started/identifiers","03.get-started/02.identifiers",false,{"title":29,"icon":30,"path":31,"stem":32,"children":33,"page":27},"Concepts","i-lucide-book-open","/concepts","04.concepts",[34],{"title":35,"path":36,"stem":37},"Limits and pricing","/concepts/limits-and-pricing","04.concepts/01.limits-and-pricing",{"title":39,"path":40,"stem":41,"children":42,"icon":103},"API reference","/api","05.api/01.index",[43,45,49,53,57],{"title":44,"path":40,"stem":41},"Overview",{"title":46,"path":47,"stem":48},"Authentication","/api/authentication","05.api/02.authentication",{"title":50,"path":51,"stem":52},"Errors","/api/errors","05.api/03.errors",{"title":54,"path":55,"stem":56},"Rate limits","/api/rate-limits","05.api/04.rate-limits",{"title":58,"children":59,"ui":98,"defaultOpen":27},"Memory",[60,69,74,79,86,91],{"title":61,"path":62,"stem":63,"badge":64},"Ingest","/api/ingest","05.api/05.ingest",{"label":65,"color":66,"variant":67,"class":68},"POST","neutral","soft","rounded-md px-1.5 ring-0 bg-(--docs-sage)/50 text-[#34372F]",{"title":70,"path":71,"stem":72,"badge":73},"Context","/api/context","05.api/06.context",{"label":65,"color":66,"variant":67,"class":68},{"title":75,"path":76,"stem":77,"badge":78},"Retrieve","/api/retrieve","05.api/07.retrieve",{"label":65,"color":66,"variant":67,"class":68},{"title":80,"path":81,"stem":82,"badge":83},"List","/api/memories","05.api/08.memories",{"label":84,"color":66,"variant":67,"class":85},"GET","rounded-md px-1.5 ring-0 bg-info/12 text-info",{"title":87,"path":88,"stem":89,"badge":90},"Get","/api/memories-get","05.api/09.memories-get",{"label":84,"color":66,"variant":67,"class":85},{"title":92,"path":93,"stem":94,"badge":95},"Delete","/api/memories-delete","05.api/10.memories-delete",{"label":96,"color":66,"variant":67,"class":97},"DEL","rounded-md px-1.5 ring-0 bg-warning/12 text-warning",{"itemWithChildren":99,"trigger":100,"linkTrailingIcon":101,"content":102},"mt-0","mb-0 text-sm font-normal normal-case tracking-normal","block","ms-2.5 ps-2 border-s border-default","i-lucide-code",{"title":105,"icon":106,"path":107,"stem":108,"children":109,"page":27},"SDKs","i-lucide-package","/sdk","06.sdk",[110,114,118],{"title":111,"path":112,"stem":113},"JavaScript","/sdk/javascript","06.sdk/01.javascript",{"title":115,"path":116,"stem":117},"PHP","/sdk/php","06.sdk/02.php",{"title":119,"path":120,"stem":121},"Python","/sdk/python","06.sdk/03.python",{"title":123,"icon":124,"path":125,"stem":126,"children":127,"page":27},"Integrations","i-lucide-blocks","/integrations","07.integrations",[128,132,136],{"title":129,"path":130,"stem":131},"Vercel AI SDK","/integrations/ai-sdk","07.integrations/01.ai-sdk",{"title":133,"path":134,"stem":135},"OpenAI Agents SDK","/integrations/openai-agents","07.integrations/02.openai-agents",{"title":137,"path":138,"stem":139},"Laravel","/integrations/laravel","07.integrations/03.laravel",{"title":141,"path":142,"stem":143},"Changelog","/changelog","08.changelog",{"id":145,"title":146,"body":147,"description":1635,"extension":1636,"links":1637,"meta":1638,"navigation":1639,"path":120,"seo":1640,"stem":121,"__hash__":1641},"docs/06.sdk/03.python.md","Python SDK",{"type":148,"value":149,"toc":1620},"minimark",[150,169,174,232,236,325,378,385,398,420,423,427,430,517,539,545,548,551,607,639,644,647,657,846,897,956,961,964,967,1029,1034,1037,1040,1068,1073,1076,1079,1101,1107,1112,1116,1126,1201,1204,1211,1289,1292,1406,1409,1438,1444,1603,1607,1616],[151,152,153,154,158,159,163,164,168],"p",{},"The ",[155,156,157],"code",{},"neurophic"," package is a typed client for the ",[160,161,162],"a",{"href":40},"REST API",". It sends requests with httpx, returns pydantic models, ships a sync and an async client, and needs ",[165,166,167],"strong",{},"Python 3.10 or later",".",[170,171,173],"h2",{"id":172},"install","Install",[175,176,178,203,218],"code-group",{"sync":177},"pm",[179,180,186],"pre",{"className":181,"code":182,"filename":183,"language":184,"meta":185,"style":185},"language-bash shiki shiki-themes github-dark-default","pip install neurophic\n","pip","bash","",[155,187,188],{"__ignoreMap":185},[189,190,193,196,200],"span",{"class":191,"line":192},"line",1,[189,194,183],{"class":195},"sQhOw",[189,197,199],{"class":198},"s9uIt"," install",[189,201,202],{"class":198}," neurophic\n",[179,204,207],{"className":181,"code":205,"filename":206,"language":184,"meta":185,"style":185},"uv add neurophic\n","uv",[155,208,209],{"__ignoreMap":185},[189,210,211,213,216],{"class":191,"line":192},[189,212,206],{"class":195},[189,214,215],{"class":198}," add",[189,217,202],{"class":198},[179,219,222],{"className":181,"code":220,"filename":221,"language":184,"meta":185,"style":185},"poetry add neurophic\n","poetry",[155,223,224],{"__ignoreMap":185},[189,225,226,228,230],{"class":191,"line":192},[189,227,221],{"class":195},[189,229,215],{"class":198},[189,231,202],{"class":198},[170,233,235],{"id":234},"create-a-client","Create a client",[179,237,241],{"className":238,"code":239,"language":240,"meta":185,"style":185},"language-python shiki shiki-themes github-dark-default","from neurophic import Neurophic\n\nclient = Neurophic(\n    api_key=\"nph_...\",\n    base_url=\"https://api.neurophic.ai\",\n    timeout=10,\n)\n","python",[155,242,243,259,266,278,292,305,319],{"__ignoreMap":185},[189,244,245,249,253,256],{"class":191,"line":192},[189,246,248],{"class":247},"suJrU","from",[189,250,252],{"class":251},"sZEs4"," neurophic ",[189,254,255],{"class":247},"import",[189,257,258],{"class":251}," Neurophic\n",[189,260,262],{"class":191,"line":261},2,[189,263,265],{"emptyLinePlaceholder":264},true,"\n",[189,267,269,272,275],{"class":191,"line":268},3,[189,270,271],{"class":251},"client ",[189,273,274],{"class":247},"=",[189,276,277],{"class":251}," Neurophic(\n",[189,279,281,284,286,289],{"class":191,"line":280},4,[189,282,283],{"class":195},"    api_key",[189,285,274],{"class":247},[189,287,288],{"class":198},"\"nph_...\"",[189,290,291],{"class":251},",\n",[189,293,295,298,300,303],{"class":191,"line":294},5,[189,296,297],{"class":195},"    base_url",[189,299,274],{"class":247},[189,301,302],{"class":198},"\"https://api.neurophic.ai\"",[189,304,291],{"class":251},[189,306,308,311,313,317],{"class":191,"line":307},6,[189,309,310],{"class":195},"    timeout",[189,312,274],{"class":247},[189,314,316],{"class":315},"sFSAA","10",[189,318,291],{"class":251},[189,320,322],{"class":191,"line":321},7,[189,323,324],{"class":251},")\n",[326,327,328,342,352,366],"ul",{},[329,330,331,334,335,338,339,168],"li",{},[155,332,333],{},"api_key",": a project key. Falls back to the ",[155,336,337],{},"NEUROPHIC_API_KEY"," environment variable; if neither is set the constructor raises ",[155,340,341],{},"ValueError",[329,343,344,347,348,351],{},[155,345,346],{},"base_url",": where requests go. Falls back to ",[155,349,350],{},"NEUROPHIC_BASE_URL",", then the production API.",[329,353,354,357,358,361,362,365],{},[155,355,356],{},"timeout",": seconds the client waits for each step of a request, an ",[155,359,360],{},"httpx.Timeout",", or ",[155,363,364],{},"None"," for no limit. Defaults to 30 seconds.",[329,367,368,371,372,375,376,168],{},[155,369,370],{},"http_client",": your own ",[155,373,374],{},"httpx.Client",", for a proxy or event hooks. It keeps its own timeout unless you set ",[155,377,356],{},[151,379,380,381,384],{},"Use the client as a context manager, or call ",[155,382,383],{},"close()",", to release its connections.",[386,387,388],"note",{},[151,389,390,391,394,395,168],{},"Pass ",[155,392,393],{},"identifier"," as the first argument of every call. Keep keys server-side; see ",[160,396,397],{"href":21},"Get started > API keys",[151,399,400,401,404,405,408,409,411,412,415,416,419],{},"Every date argument takes an ISO 8601 string, a ",[155,402,403],{},"date"," or a ",[155,406,407],{},"datetime","; a naive ",[155,410,407],{}," is sent as UTC. Wherever a role or rerank mode is accepted, pass a plain string or the ",[155,413,414],{},"MemoryRole"," and ",[155,417,418],{},"RerankMode"," enums.",[170,421,58],{"id":422},"memory",[424,425,61],"h3",{"id":426},"ingest",[151,428,429],{},"Stores a memory. The write is queued, not written on the spot.",[179,431,433],{"className":238,"code":432,"language":240,"meta":185,"style":185},"receipt = client.ingest(\n    \"user-123\",\n    \"Prefers window seats on long flights.\",\n    name=\"Ada\",\n    occurred_at=\"2026-08-12T09:12:00Z\",\n    role=\"user\",\n)\n\nprint(receipt.id, receipt.status)  # the memory id once the write is processed, \"queued\"\n",[155,434,435,445,452,459,471,483,495,499,504],{"__ignoreMap":185},[189,436,437,440,442],{"class":191,"line":192},[189,438,439],{"class":251},"receipt ",[189,441,274],{"class":247},[189,443,444],{"class":251}," client.ingest(\n",[189,446,447,450],{"class":191,"line":261},[189,448,449],{"class":198},"    \"user-123\"",[189,451,291],{"class":251},[189,453,454,457],{"class":191,"line":268},[189,455,456],{"class":198},"    \"Prefers window seats on long flights.\"",[189,458,291],{"class":251},[189,460,461,464,466,469],{"class":191,"line":280},[189,462,463],{"class":195},"    name",[189,465,274],{"class":247},[189,467,468],{"class":198},"\"Ada\"",[189,470,291],{"class":251},[189,472,473,476,478,481],{"class":191,"line":294},[189,474,475],{"class":195},"    occurred_at",[189,477,274],{"class":247},[189,479,480],{"class":198},"\"2026-08-12T09:12:00Z\"",[189,482,291],{"class":251},[189,484,485,488,490,493],{"class":191,"line":307},[189,486,487],{"class":195},"    role",[189,489,274],{"class":247},[189,491,492],{"class":198},"\"user\"",[189,494,291],{"class":251},[189,496,497],{"class":191,"line":321},[189,498,324],{"class":251},[189,500,502],{"class":191,"line":501},8,[189,503,265],{"emptyLinePlaceholder":264},[189,505,507,510,513],{"class":191,"line":506},9,[189,508,509],{"class":315},"print",[189,511,512],{"class":251},"(receipt.id, receipt.status)  ",[189,514,516],{"class":515},"sH3jZ","# the memory id once the write is processed, \"queued\"\n",[326,518,519,525],{},[329,520,521,524],{},[155,522,523],{},"occurred_at",": when the content was said. Defaults to now; set it when backfilling history, oldest first.",[329,526,527,530,531,534,535,538],{},[155,528,529],{},"role",": who said it, ",[155,532,533],{},"user"," by default. Store your agent's own replies as ",[155,536,537],{},"assistant","; they never replace what the person said.",[151,540,541,542,168],{},"Learn more under ",[160,543,544],{"href":62},"API reference > Ingest",[424,546,70],{"id":547},"context",[151,549,550],{},"Fetches a short, ready-to-prompt summary for a query, as a string. It is empty when nothing is relevant.",[179,552,554],{"className":238,"code":553,"language":240,"meta":185,"style":185},"context = client.context(\n    \"user-123\",\n    \"Booking a flight to Lisbon next month\",\n    sources=True,\n    rerank=\"fast\",\n)\n",[155,555,556,566,572,579,591,603],{"__ignoreMap":185},[189,557,558,561,563],{"class":191,"line":192},[189,559,560],{"class":251},"context ",[189,562,274],{"class":247},[189,564,565],{"class":251}," client.context(\n",[189,567,568,570],{"class":191,"line":261},[189,569,449],{"class":198},[189,571,291],{"class":251},[189,573,574,577],{"class":191,"line":268},[189,575,576],{"class":198},"    \"Booking a flight to Lisbon next month\"",[189,578,291],{"class":251},[189,580,581,584,586,589],{"class":191,"line":280},[189,582,583],{"class":195},"    sources",[189,585,274],{"class":247},[189,587,588],{"class":315},"True",[189,590,291],{"class":251},[189,592,593,596,598,601],{"class":191,"line":294},[189,594,595],{"class":195},"    rerank",[189,597,274],{"class":247},[189,599,600],{"class":198},"\"fast\"",[189,602,291],{"class":251},[189,604,605],{"class":191,"line":307},[189,606,324],{"class":251},[326,608,609,619,625],{},[329,610,611,614,615,618],{},[155,612,613],{},"roles",": whose words to include, the person's own by default. Add ",[155,616,617],{},"\"assistant\""," for what your agent said.",[329,620,621,624],{},[155,622,623],{},"sources",": also return the original turns, each once: the turns behind the block, plus up to five that match the query directly.",[329,626,627,630,631,634,635,638],{},[155,628,629],{},"rerank",": a second ranking stage before the cut, ",[155,632,633],{},"fast"," or ",[155,636,637],{},"thorough",". Off by default; a paid mode adds the reranking model's cost to the request.",[151,640,541,641,168],{},[160,642,643],{"href":71},"API reference > Context",[424,645,75],{"id":646},"retrieve",[151,648,649,650,653,654,168],{},"Searches memory. The return type follows ",[155,651,652],{},"format",": Markdown ready to drop into a prompt by default, the same results as typed objects with ",[155,655,656],{},"format=\"json\"",[179,658,660],{"className":238,"code":659,"language":240,"meta":185,"style":185},"markdown = client.retrieve(\"user-123\", \"travel preferences\")\n\nresult = client.retrieve(\n    \"user-123\",\n    \"travel preferences\",\n    goal=\"book a flight for the user\",\n    since=\"2026-08-01T00:00:00Z\",\n    roles=[\"user\", \"assistant\"],\n    limit=10,\n    reference_date=\"2026-08-19\",\n    format=\"json\",\n    sources=True,\n    rerank=\"fast\",\n)\n\nfor memory in result.memories:\n    print(memory.content)\n",[155,661,662,683,687,697,703,710,722,734,753,764,777,790,801,812,817,822,837],{"__ignoreMap":185},[189,663,664,667,669,672,675,678,681],{"class":191,"line":192},[189,665,666],{"class":251},"markdown ",[189,668,274],{"class":247},[189,670,671],{"class":251}," client.retrieve(",[189,673,674],{"class":198},"\"user-123\"",[189,676,677],{"class":251},", ",[189,679,680],{"class":198},"\"travel preferences\"",[189,682,324],{"class":251},[189,684,685],{"class":191,"line":261},[189,686,265],{"emptyLinePlaceholder":264},[189,688,689,692,694],{"class":191,"line":268},[189,690,691],{"class":251},"result ",[189,693,274],{"class":247},[189,695,696],{"class":251}," client.retrieve(\n",[189,698,699,701],{"class":191,"line":280},[189,700,449],{"class":198},[189,702,291],{"class":251},[189,704,705,708],{"class":191,"line":294},[189,706,707],{"class":198},"    \"travel preferences\"",[189,709,291],{"class":251},[189,711,712,715,717,720],{"class":191,"line":307},[189,713,714],{"class":195},"    goal",[189,716,274],{"class":247},[189,718,719],{"class":198},"\"book a flight for the user\"",[189,721,291],{"class":251},[189,723,724,727,729,732],{"class":191,"line":321},[189,725,726],{"class":195},"    since",[189,728,274],{"class":247},[189,730,731],{"class":198},"\"2026-08-01T00:00:00Z\"",[189,733,291],{"class":251},[189,735,736,739,741,744,746,748,750],{"class":191,"line":501},[189,737,738],{"class":195},"    roles",[189,740,274],{"class":247},[189,742,743],{"class":251},"[",[189,745,492],{"class":198},[189,747,677],{"class":251},[189,749,617],{"class":198},[189,751,752],{"class":251},"],\n",[189,754,755,758,760,762],{"class":191,"line":506},[189,756,757],{"class":195},"    limit",[189,759,274],{"class":247},[189,761,316],{"class":315},[189,763,291],{"class":251},[189,765,767,770,772,775],{"class":191,"line":766},10,[189,768,769],{"class":195},"    reference_date",[189,771,274],{"class":247},[189,773,774],{"class":198},"\"2026-08-19\"",[189,776,291],{"class":251},[189,778,780,783,785,788],{"class":191,"line":779},11,[189,781,782],{"class":195},"    format",[189,784,274],{"class":247},[189,786,787],{"class":198},"\"json\"",[189,789,291],{"class":251},[189,791,793,795,797,799],{"class":191,"line":792},12,[189,794,583],{"class":195},[189,796,274],{"class":247},[189,798,588],{"class":315},[189,800,291],{"class":251},[189,802,804,806,808,810],{"class":191,"line":803},13,[189,805,595],{"class":195},[189,807,274],{"class":247},[189,809,600],{"class":198},[189,811,291],{"class":251},[189,813,815],{"class":191,"line":814},14,[189,816,324],{"class":251},[189,818,820],{"class":191,"line":819},15,[189,821,265],{"emptyLinePlaceholder":264},[189,823,825,828,831,834],{"class":191,"line":824},16,[189,826,827],{"class":247},"for",[189,829,830],{"class":251}," memory ",[189,832,833],{"class":247},"in",[189,835,836],{"class":251}," result.memories:\n",[189,838,840,843],{"class":191,"line":839},17,[189,841,842],{"class":315},"    print",[189,844,845],{"class":251},"(memory.content)\n",[326,847,848,857,865,878,891],{},[329,849,850,677,853,856],{},[155,851,852],{},"since",[155,854,855],{},"until",": only memories observed in that window.",[329,858,859,861,862,864],{},[155,860,613],{},": whose words to return, the person's own by default. Add ",[155,863,617],{}," for what your agent said; patterns are always the person's.",[329,866,867,869,870,873,874,877],{},[155,868,623],{},": also return the original turns, each once, as ",[155,871,872],{},"result.sources",", with ",[155,875,876],{},"source_id"," on each memory they were taken from.",[329,879,880,630,882,634,884,886,887,890],{},[155,881,629],{},[155,883,633],{},[155,885,637],{},". Off by default; a paid mode adds the reranking model's cost to the request, and ",[155,888,889],{},"limit"," still applies after it.",[329,892,893,896],{},[155,894,895],{},"reference_date",": the day relative time in the query, such as \"last week\", is read from. Defaults to today.",[151,898,899,900,902,903,906,907,677,910,677,913,415,916,918,919,677,922,677,925,415,928,931,932,677,934,937,938,940,941,937,943,945,946,949,950,952,953,955],{},"With ",[155,901,656],{}," the result is a ",[155,904,905],{},"RetrieveResult"," holding ",[155,908,909],{},"memories",[155,911,912],{},"observations",[155,914,915],{},"patterns",[155,917,623],{},", as lists of ",[155,920,921],{},"RetrievedMemory",[155,923,924],{},"RetrievedObservation",[155,926,927],{},"RetrievedPattern",[155,929,930],{},"RetrievedSource",". Timestamps are ",[155,933,407],{},[155,935,936],{},"event_date"," is a ",[155,939,403],{},", and each ",[155,942,529],{},[155,944,414],{},", or plain text for a role this version of the client does not know. ",[155,947,948],{},"relevance"," is ",[155,951,364],{}," when ",[155,954,629],{}," was used; the order of the list is then the ranking.",[151,957,541,958,168],{},[160,959,960],{"href":76},"API reference > Retrieve",[424,962,80],{"id":963},"list",[151,965,966],{},"Pages through every memory stored for an identifier, newest first.",[179,968,970],{"className":238,"code":969,"language":240,"meta":185,"style":185},"page = client.memory.list(\"user-123\", page=2, per_page=10)\n\nprint(page.total)\nprint(page.memories[0].content)\n",[155,971,972,1005,1009,1016],{"__ignoreMap":185},[189,973,974,977,979,982,984,986,989,991,994,996,999,1001,1003],{"class":191,"line":192},[189,975,976],{"class":251},"page ",[189,978,274],{"class":247},[189,980,981],{"class":251}," client.memory.list(",[189,983,674],{"class":198},[189,985,677],{"class":251},[189,987,988],{"class":195},"page",[189,990,274],{"class":247},[189,992,993],{"class":315},"2",[189,995,677],{"class":251},[189,997,998],{"class":195},"per_page",[189,1000,274],{"class":247},[189,1002,316],{"class":315},[189,1004,324],{"class":251},[189,1006,1007],{"class":191,"line":261},[189,1008,265],{"emptyLinePlaceholder":264},[189,1010,1011,1013],{"class":191,"line":268},[189,1012,509],{"class":315},[189,1014,1015],{"class":251},"(page.total)\n",[189,1017,1018,1020,1023,1026],{"class":191,"line":280},[189,1019,509],{"class":315},[189,1021,1022],{"class":251},"(page.memories[",[189,1024,1025],{"class":315},"0",[189,1027,1028],{"class":251},"].content)\n",[151,1030,541,1031,168],{},[160,1032,1033],{"href":81},"API reference > List",[424,1035,87],{"id":1036},"get",[151,1038,1039],{},"Fetches one memory by id.",[179,1041,1043],{"className":238,"code":1042,"language":240,"meta":185,"style":185},"memory = client.memory.get(\"5f1d2c3e-...\", identifier=\"user-123\")\n",[155,1044,1045],{"__ignoreMap":185},[189,1046,1047,1050,1052,1055,1058,1060,1062,1064,1066],{"class":191,"line":192},[189,1048,1049],{"class":251},"memory ",[189,1051,274],{"class":247},[189,1053,1054],{"class":251}," client.memory.get(",[189,1056,1057],{"class":198},"\"5f1d2c3e-...\"",[189,1059,677],{"class":251},[189,1061,393],{"class":195},[189,1063,274],{"class":247},[189,1065,674],{"class":198},[189,1067,324],{"class":251},[151,1069,541,1070,168],{},[160,1071,1072],{"href":88},"API reference > Get",[424,1074,92],{"id":1075},"delete",[151,1077,1078],{},"Deletes one memory by id.",[179,1080,1082],{"className":238,"code":1081,"language":240,"meta":185,"style":185},"client.memory.delete(\"5f1d2c3e-...\", identifier=\"user-123\")\n",[155,1083,1084],{"__ignoreMap":185},[189,1085,1086,1089,1091,1093,1095,1097,1099],{"class":191,"line":192},[189,1087,1088],{"class":251},"client.memory.delete(",[189,1090,1057],{"class":198},[189,1092,677],{"class":251},[189,1094,393],{"class":195},[189,1096,274],{"class":247},[189,1098,674],{"class":198},[189,1100,324],{"class":251},[151,1102,390,1103,1106],{},[155,1104,1105],{},"restore_previous=True"," to delete only this version and restore the one it superseded.",[151,1108,541,1109,168],{},[160,1110,1111],{"href":93},"API reference > Delete",[170,1113,1115],{"id":1114},"async","Async",[151,1117,1118,1121,1122,1125],{},[155,1119,1120],{},"AsyncNeurophic"," has the same calls and options, awaited. Close it with ",[155,1123,1124],{},"aclose()",", or use it as an async context manager.",[179,1127,1129],{"className":238,"code":1128,"language":240,"meta":185,"style":185},"from neurophic import AsyncNeurophic\n\nasync with AsyncNeurophic() as client:\n    await client.ingest(\"user-123\", \"Prefers window seats on long flights.\")\n    context = await client.context(\"user-123\", \"Booking a flight to Lisbon next month\")\n",[155,1130,1131,1142,1146,1162,1179],{"__ignoreMap":185},[189,1132,1133,1135,1137,1139],{"class":191,"line":192},[189,1134,248],{"class":247},[189,1136,252],{"class":251},[189,1138,255],{"class":247},[189,1140,1141],{"class":251}," AsyncNeurophic\n",[189,1143,1144],{"class":191,"line":261},[189,1145,265],{"emptyLinePlaceholder":264},[189,1147,1148,1150,1153,1156,1159],{"class":191,"line":268},[189,1149,1114],{"class":247},[189,1151,1152],{"class":247}," with",[189,1154,1155],{"class":251}," AsyncNeurophic() ",[189,1157,1158],{"class":247},"as",[189,1160,1161],{"class":251}," client:\n",[189,1163,1164,1167,1170,1172,1174,1177],{"class":191,"line":280},[189,1165,1166],{"class":247},"    await",[189,1168,1169],{"class":251}," client.ingest(",[189,1171,674],{"class":198},[189,1173,677],{"class":251},[189,1175,1176],{"class":198},"\"Prefers window seats on long flights.\"",[189,1178,324],{"class":251},[189,1180,1181,1184,1186,1189,1192,1194,1196,1199],{"class":191,"line":294},[189,1182,1183],{"class":251},"    context ",[189,1185,274],{"class":247},[189,1187,1188],{"class":247}," await",[189,1190,1191],{"class":251}," client.context(",[189,1193,674],{"class":198},[189,1195,677],{"class":251},[189,1197,1198],{"class":198},"\"Booking a flight to Lisbon next month\"",[189,1200,324],{"class":251},[170,1202,50],{"id":1203},"errors",[151,1205,1206,1207,1210],{},"Every HTTP and transport failure raises ",[155,1208,1209],{},"neurophic.NeurophicError",", carrying:",[1212,1213,1214,1225,1251,1257,1271,1278],"field-group",{},[1215,1216,1219],"field",{"name":1217,"type":1218},"status_code","int",[151,1220,1221,1222,1224],{},"The HTTP status; ",[155,1223,1025],{}," for timeouts and connection failures.",[1215,1226,1228],{"name":155,"type":1227},"str",[151,1229,1230,1231,1234,1235,1238,1239,1242,1243,1246,1247,1250],{},"The API error code, for example ",[155,1232,1233],{},"VALIDATION_ERROR","; see ",[160,1236,1237],{"href":51},"API reference > Errors",". Compare it to the ",[155,1240,1241],{},"ErrorCode"," constants. ",[155,1244,1245],{},"UNKNOWN"," when the body is not the standard envelope, for example a plain-text ",[155,1248,1249],{},"413"," from the edge.",[1215,1252,1254],{"name":1253,"type":1227},"message",[151,1255,1256],{},"The API message.",[1215,1258,1261],{"name":1259,"type":1260},"details","list[ValidationDetail]",[151,1262,1263,1264,1266,1267,415,1269,168],{},"The field-level problems on a ",[155,1265,1233],{},", each with ",[155,1268,1215],{},[155,1270,1253],{},[1215,1272,1275],{"name":1273,"type":1274},"body","Any",[151,1276,1277],{},"The raw response body, decoded from JSON when possible.",[1215,1279,1282],{"name":1280,"type":1281},"retry_after","float | None",[151,1283,1284,1285,1288],{},"Seconds to wait, from the ",[155,1286,1287],{},"Retry-After"," header when the API sent one.",[151,1290,1291],{},"A response outside the 2xx range raises the subclass for its status, so you can catch what you expect by name:",[1293,1294,1295,1308],"table",{},[1296,1297,1298],"thead",{},[1299,1300,1301,1305],"tr",{},[1302,1303,1304],"th",{},"Status",[1302,1306,1307],{},"Class",[1309,1310,1311,1325,1335,1351,1361,1371,1381,1391],"tbody",{},[1299,1312,1313,1317],{},[1314,1315,1316],"td",{},"400",[1314,1318,1319,873,1322,1324],{},[155,1320,1321],{},"BadRequestError",[155,1323,1259],{}," on a validation error",[1299,1326,1327,1330],{},[1314,1328,1329],{},"401",[1314,1331,1332],{},[155,1333,1334],{},"AuthenticationError",[1299,1336,1337,1340],{},[1314,1338,1339],{},"402",[1314,1341,1342,873,1345,415,1348],{},[155,1343,1344],{},"InsufficientCreditError",[155,1346,1347],{},"balance",[155,1349,1350],{},"required",[1299,1352,1353,1356],{},[1314,1354,1355],{},"403",[1314,1357,1358],{},[155,1359,1360],{},"PermissionDeniedError",[1299,1362,1363,1366],{},[1314,1364,1365],{},"404",[1314,1367,1368],{},[155,1369,1370],{},"NotFoundError",[1299,1372,1373,1376],{},[1314,1374,1375],{},"409",[1314,1377,1378],{},[155,1379,1380],{},"MemoryLimitError",[1299,1382,1383,1386],{},[1314,1384,1385],{},"429",[1314,1387,1388],{},[155,1389,1390],{},"RateLimitError",[1299,1392,1393,1396],{},[1314,1394,1395],{},"5xx",[1314,1397,1398,1401,1402,1405],{},[155,1399,1400],{},"InternalServerError",", and ",[155,1403,1404],{},"ServiceUnavailableError"," for 503",[151,1407,1408],{},"Three more subclasses cover failures that never reach the API, or that it did not answer as expected:",[326,1410,1411,1419,1430],{},[329,1412,1413,1418],{},[165,1414,1415,168],{},[155,1416,1417],{},"NeurophicTimeoutError"," The client stopped waiting; the API may still have handled the request.",[329,1420,1421,1426,1427,168],{},[165,1422,1423,168],{},[155,1424,1425],{},"NeurophicConnectionError"," A network failure, with the cause as ",[155,1428,1429],{},"__cause__",[329,1431,1432,1437],{},[165,1433,1434,168],{},[155,1435,1436],{},"InvalidResponseError"," A success status with a body the client cannot read, not JSON or not the expected shape. It usually means the API has changed and the client needs updating.",[1439,1440,1441],"tip",{},[151,1442,1443],{},"The client never retries; add your own backoff if you need it.",[179,1445,1447],{"className":238,"code":1446,"language":240,"meta":185,"style":185},"from neurophic import BadRequestError, InsufficientCreditError, Neurophic, NeurophicError, NeurophicTimeoutError\n\nclient = Neurophic()\n\ntry:\n    client.ingest(\"user-123\", \"Prefers window seats.\")\nexcept NeurophicTimeoutError:\n    print(\"No reply in time; the write may still go through.\")\nexcept BadRequestError as error:\n    print(error.message, error.details)\nexcept InsufficientCreditError as error:\n    print(f\"Balance {error.balance}, required {error.required}. Top up the project.\")\nexcept NeurophicError as error:\n    print(error.status_code, error.code, error.message)\n",[155,1448,1449,1460,1464,1473,1477,1485,1499,1507,1519,1531,1538,1549,1585,1596],{"__ignoreMap":185},[189,1450,1451,1453,1455,1457],{"class":191,"line":192},[189,1452,248],{"class":247},[189,1454,252],{"class":251},[189,1456,255],{"class":247},[189,1458,1459],{"class":251}," BadRequestError, InsufficientCreditError, Neurophic, NeurophicError, NeurophicTimeoutError\n",[189,1461,1462],{"class":191,"line":261},[189,1463,265],{"emptyLinePlaceholder":264},[189,1465,1466,1468,1470],{"class":191,"line":268},[189,1467,271],{"class":251},[189,1469,274],{"class":247},[189,1471,1472],{"class":251}," Neurophic()\n",[189,1474,1475],{"class":191,"line":280},[189,1476,265],{"emptyLinePlaceholder":264},[189,1478,1479,1482],{"class":191,"line":294},[189,1480,1481],{"class":247},"try",[189,1483,1484],{"class":251},":\n",[189,1486,1487,1490,1492,1494,1497],{"class":191,"line":307},[189,1488,1489],{"class":251},"    client.ingest(",[189,1491,674],{"class":198},[189,1493,677],{"class":251},[189,1495,1496],{"class":198},"\"Prefers window seats.\"",[189,1498,324],{"class":251},[189,1500,1501,1504],{"class":191,"line":321},[189,1502,1503],{"class":247},"except",[189,1505,1506],{"class":251}," NeurophicTimeoutError:\n",[189,1508,1509,1511,1514,1517],{"class":191,"line":501},[189,1510,842],{"class":315},[189,1512,1513],{"class":251},"(",[189,1515,1516],{"class":198},"\"No reply in time; the write may still go through.\"",[189,1518,324],{"class":251},[189,1520,1521,1523,1526,1528],{"class":191,"line":506},[189,1522,1503],{"class":247},[189,1524,1525],{"class":251}," BadRequestError ",[189,1527,1158],{"class":247},[189,1529,1530],{"class":251}," error:\n",[189,1532,1533,1535],{"class":191,"line":766},[189,1534,842],{"class":315},[189,1536,1537],{"class":251},"(error.message, error.details)\n",[189,1539,1540,1542,1545,1547],{"class":191,"line":779},[189,1541,1503],{"class":247},[189,1543,1544],{"class":251}," InsufficientCreditError ",[189,1546,1158],{"class":247},[189,1548,1530],{"class":251},[189,1550,1551,1553,1555,1558,1561,1564,1567,1570,1573,1575,1578,1580,1583],{"class":191,"line":792},[189,1552,842],{"class":315},[189,1554,1513],{"class":251},[189,1556,1557],{"class":247},"f",[189,1559,1560],{"class":198},"\"Balance ",[189,1562,1563],{"class":247},"{",[189,1565,1566],{"class":251},"error.balance",[189,1568,1569],{"class":247},"}",[189,1571,1572],{"class":198},", required ",[189,1574,1563],{"class":247},[189,1576,1577],{"class":251},"error.required",[189,1579,1569],{"class":247},[189,1581,1582],{"class":198},". Top up the project.\"",[189,1584,324],{"class":251},[189,1586,1587,1589,1592,1594],{"class":191,"line":803},[189,1588,1503],{"class":247},[189,1590,1591],{"class":251}," NeurophicError ",[189,1593,1158],{"class":247},[189,1595,1530],{"class":251},[189,1597,1598,1600],{"class":191,"line":814},[189,1599,842],{"class":315},[189,1601,1602],{"class":251},"(error.status_code, error.code, error.message)\n",[170,1604,1606],{"id":1605},"licence","Licence",[151,1608,1609,1610,168],{},"The SDK is MIT-licensed; use of the API it calls is governed by the ",[160,1611,1615],{"href":1612,"rel":1613},"https://neurophic.ai/policies/terms-of-use",[1614],"nofollow","Terms of Use",[1617,1618,1619],"style",{},"html pre.shiki code .sQhOw, html code.shiki .sQhOw{--shiki-default:#FFA657}html pre.shiki code .s9uIt, html code.shiki .s9uIt{--shiki-default:#A5D6FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .suJrU, html code.shiki .suJrU{--shiki-default:#FF7B72}html pre.shiki code .sZEs4, html code.shiki .sZEs4{--shiki-default:#E6EDF3}html pre.shiki code .sFSAA, html code.shiki .sFSAA{--shiki-default:#79C0FF}html pre.shiki code .sH3jZ, html code.shiki .sH3jZ{--shiki-default:#8B949E}",{"title":185,"searchDepth":192,"depth":261,"links":1621},[1622,1623,1624,1632,1633,1634],{"id":172,"depth":261,"text":173},{"id":234,"depth":261,"text":235},{"id":422,"depth":261,"text":58,"children":1625},[1626,1627,1628,1629,1630,1631],{"id":426,"depth":268,"text":61},{"id":547,"depth":268,"text":70},{"id":646,"depth":268,"text":75},{"id":963,"depth":268,"text":80},{"id":1036,"depth":268,"text":87},{"id":1075,"depth":268,"text":92},{"id":1114,"depth":261,"text":1115},{"id":1203,"depth":261,"text":50},{"id":1605,"depth":261,"text":1606},"Install the Python SDK, create a client and call every endpoint from Python 3.10 or later","md",null,{},{"title":119},{"title":146,"description":1635},"uX3Ze9rGy_nvzxT8BvtG2DjfB7l9OhSLTT-svS9Po64",[1643,1645],{"title":115,"path":116,"stem":117,"description":1644,"children":-1},"Install the PHP SDK, create a client and call every endpoint from PHP 8.2 or later",{"title":129,"path":130,"stem":131,"description":1646,"children":-1},"Give a Vercel AI SDK model memory with ready-made tools and prompt context",1796467715067]