[{"data":1,"prerenderedAt":1012},["ShallowReactive",2],{"navigation":3,"/integrations/openai-agents":144,"/integrations/openai-agents-surround":1007},[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":133,"body":146,"description":1001,"extension":941,"links":1002,"meta":1003,"navigation":1004,"path":134,"seo":1005,"stem":135,"__hash__":1006},"docs/07.integrations/02.openai-agents.md",{"type":147,"value":148,"toc":995},"minimark",[149,173,178,257,261,530,539,585,606,616,622,626,642,788,791,834,839,843,852,934,937,967,986,991],[150,151,152,156,157,161,162,167,168,172],"p",{},[153,154,155],"code",{},"@neurophic/openai-agents"," wraps the ",[158,159,160],"a",{"href":112},"JavaScript SDK"," for the ",[158,163,133],{"href":164,"rel":165},"https://openai.github.io/openai-agents-js/",[166],"nofollow",". It needs ",[169,170,171],"strong",{},"Node 22 or later",", the runtime the Agents SDK needs.",[174,175,177],"h2",{"id":176},"install","Install",[179,180,182,216,237],"code-group",{"sync":181},"pm",[183,184,190],"pre",{"className":185,"code":186,"filename":187,"language":188,"meta":189,"style":189},"language-bash shiki shiki-themes github-dark-default","npm install neurophic @neurophic/openai-agents @openai/agents zod\n","npm","bash","",[153,191,192],{"__ignoreMap":189},[193,194,197,200,204,207,210,213],"span",{"class":195,"line":196},"line",1,[193,198,187],{"class":199},"sQhOw",[193,201,203],{"class":202},"s9uIt"," install",[193,205,206],{"class":202}," neurophic",[193,208,209],{"class":202}," @neurophic/openai-agents",[193,211,212],{"class":202}," @openai/agents",[193,214,215],{"class":202}," zod\n",[183,217,220],{"className":185,"code":218,"filename":219,"language":188,"meta":189,"style":189},"pnpm add neurophic @neurophic/openai-agents @openai/agents zod\n","pnpm",[153,221,222],{"__ignoreMap":189},[193,223,224,226,229,231,233,235],{"class":195,"line":196},[193,225,219],{"class":199},[193,227,228],{"class":202}," add",[193,230,206],{"class":202},[193,232,209],{"class":202},[193,234,212],{"class":202},[193,236,215],{"class":202},[183,238,241],{"className":185,"code":239,"filename":240,"language":188,"meta":189,"style":189},"yarn add neurophic @neurophic/openai-agents @openai/agents zod\n","yarn",[153,242,243],{"__ignoreMap":189},[193,244,245,247,249,251,253,255],{"class":195,"line":196},[193,246,240],{"class":199},[193,248,228],{"class":202},[193,250,206],{"class":202},[193,252,209],{"class":202},[193,254,212],{"class":202},[193,256,215],{"class":202},[174,258,260],{"id":259},"createtools","createTools",[183,262,266],{"className":263,"code":264,"language":265,"meta":189,"style":189},"language-ts shiki shiki-themes github-dark-default","import { Agent, run } from '@openai/agents';\nimport { createTools } from '@neurophic/openai-agents';\nimport { Neurophic } from 'neurophic';\n\nconst client = new Neurophic({ apiKey: process.env.NEUROPHIC_API_KEY });\nconst { remember, recall } = createTools({\n  client,\n  identifier: 'user-123',\n  name: 'Ada',\n  search: { roles: ['user', 'assistant'], sources: true, rerank: 'fast' },\n});\n\nconst agent = new Agent({\n  name: 'Travel assistant',\n  instructions: 'Use recall before answering and remember what the user shares.',\n  tools: [remember, recall],\n});\n\nconst result = await run(agent, 'Remember that I prefer window seats on long flights.');\n","ts",[153,267,268,287,302,317,324,353,382,388,400,411,440,446,451,468,478,489,495,500,505],{"__ignoreMap":189},[193,269,270,274,278,281,284],{"class":195,"line":196},[193,271,273],{"class":272},"suJrU","import",[193,275,277],{"class":276},"sZEs4"," { Agent, run } ",[193,279,280],{"class":272},"from",[193,282,283],{"class":202}," '@openai/agents'",[193,285,286],{"class":276},";\n",[193,288,290,292,295,297,300],{"class":195,"line":289},2,[193,291,273],{"class":272},[193,293,294],{"class":276}," { createTools } ",[193,296,280],{"class":272},[193,298,299],{"class":202}," '@neurophic/openai-agents'",[193,301,286],{"class":276},[193,303,305,307,310,312,315],{"class":195,"line":304},3,[193,306,273],{"class":272},[193,308,309],{"class":276}," { Neurophic } ",[193,311,280],{"class":272},[193,313,314],{"class":202}," 'neurophic'",[193,316,286],{"class":276},[193,318,320],{"class":195,"line":319},4,[193,321,323],{"emptyLinePlaceholder":322},true,"\n",[193,325,327,330,334,337,340,344,347,350],{"class":195,"line":326},5,[193,328,329],{"class":272},"const",[193,331,333],{"class":332},"sFSAA"," client",[193,335,336],{"class":272}," =",[193,338,339],{"class":272}," new",[193,341,343],{"class":342},"sc3cj"," Neurophic",[193,345,346],{"class":276},"({ apiKey: process.env.",[193,348,349],{"class":332},"NEUROPHIC_API_KEY",[193,351,352],{"class":276}," });\n",[193,354,356,358,361,364,367,370,373,376,379],{"class":195,"line":355},6,[193,357,329],{"class":272},[193,359,360],{"class":276}," { ",[193,362,363],{"class":332},"remember",[193,365,366],{"class":276},", ",[193,368,369],{"class":332},"recall",[193,371,372],{"class":276}," } ",[193,374,375],{"class":272},"=",[193,377,378],{"class":342}," createTools",[193,380,381],{"class":276},"({\n",[193,383,385],{"class":195,"line":384},7,[193,386,387],{"class":276},"  client,\n",[193,389,391,394,397],{"class":195,"line":390},8,[193,392,393],{"class":276},"  identifier: ",[193,395,396],{"class":202},"'user-123'",[193,398,399],{"class":276},",\n",[193,401,403,406,409],{"class":195,"line":402},9,[193,404,405],{"class":276},"  name: ",[193,407,408],{"class":202},"'Ada'",[193,410,399],{"class":276},[193,412,414,417,420,422,425,428,431,434,437],{"class":195,"line":413},10,[193,415,416],{"class":276},"  search: { roles: [",[193,418,419],{"class":202},"'user'",[193,421,366],{"class":276},[193,423,424],{"class":202},"'assistant'",[193,426,427],{"class":276},"], sources: ",[193,429,430],{"class":332},"true",[193,432,433],{"class":276},", rerank: ",[193,435,436],{"class":202},"'fast'",[193,438,439],{"class":276}," },\n",[193,441,443],{"class":195,"line":442},11,[193,444,445],{"class":276},"});\n",[193,447,449],{"class":195,"line":448},12,[193,450,323],{"emptyLinePlaceholder":322},[193,452,454,456,459,461,463,466],{"class":195,"line":453},13,[193,455,329],{"class":272},[193,457,458],{"class":332}," agent",[193,460,336],{"class":272},[193,462,339],{"class":272},[193,464,465],{"class":342}," Agent",[193,467,381],{"class":276},[193,469,471,473,476],{"class":195,"line":470},14,[193,472,405],{"class":276},[193,474,475],{"class":202},"'Travel assistant'",[193,477,399],{"class":276},[193,479,481,484,487],{"class":195,"line":480},15,[193,482,483],{"class":276},"  instructions: ",[193,485,486],{"class":202},"'Use recall before answering and remember what the user shares.'",[193,488,399],{"class":276},[193,490,492],{"class":195,"line":491},16,[193,493,494],{"class":276},"  tools: [remember, recall],\n",[193,496,498],{"class":195,"line":497},17,[193,499,445],{"class":276},[193,501,503],{"class":195,"line":502},18,[193,504,323],{"emptyLinePlaceholder":322},[193,506,508,510,513,515,518,521,524,527],{"class":195,"line":507},19,[193,509,329],{"class":272},[193,511,512],{"class":332}," result",[193,514,336],{"class":272},[193,516,517],{"class":272}," await",[193,519,520],{"class":342}," run",[193,522,523],{"class":276},"(agent, ",[193,525,526],{"class":202},"'Remember that I prefer window seats on long flights.'",[193,528,529],{"class":276},");\n",[150,531,532,534,535,538],{},[153,533,260],{}," returns two tools for an ",[153,536,537],{},"Agent",":",[540,541,542,558],"ul",{},[543,544,545,550,551,554,555,549],"li",{},[169,546,547,549],{},[153,548,363],{},"."," Takes ",[153,552,553],{},"content","; see ",[158,556,557],{"href":62},"API reference > Ingest",[543,559,560,550,564,567,568,366,571,366,574,567,577,580,581,584],{},[169,561,562,549],{},[153,563,369],{},[153,565,566],{},"query"," and ",[153,569,570],{},"goal",[153,572,573],{},"since",[153,575,576],{},"until",[153,578,579],{},"limit",", each nullable; see ",[158,582,583],{"href":76},"API reference > Retrieve",". It returns the memories as Markdown.",[150,586,587,590,591,593,594,597,598,601,602,605],{},[153,588,589],{},"search"," is applied to every ",[153,592,369],{}," call and is set by you, never by the model: ",[153,595,596],{},"roles"," for whose words to return, ",[153,599,600],{},"sources"," to also return the original turns, and ",[153,603,604],{},"rerank"," for a second ranking stage before the cut.",[150,607,608,609,611,612,615],{},"The Agents SDK uses strict tool schemas, where every field must be present, so the optional ",[153,610,369],{}," parameters are nullable rather than optional. The model sends ",[153,613,614],{},"null"," for the ones it does not use.",[617,618,619],"warning",{},[150,620,621],{},"If a memory call fails, the model is told that memory is unavailable and the run carries on without it. Nothing is thrown.",[174,623,625],{"id":624},"createcontextfilter","createContextFilter",[150,627,628,630,631,634,635,638,639,549],{},[153,629,625],{}," puts the memories relevant to the latest user message in front of the model on every turn, with no tool call. It returns a ",[153,632,633],{},"callModelInputFilter",", which the Agents SDK runs before each model call; pass it to ",[153,636,637],{},"run()"," or to a ",[153,640,641],{},"Runner",[183,643,645],{"className":263,"code":644,"language":265,"meta":189,"style":189},"import { Agent, run } from '@openai/agents';\nimport { createContextFilter } from '@neurophic/openai-agents';\nimport { Neurophic } from 'neurophic';\n\nconst client = new Neurophic({ apiKey: process.env.NEUROPHIC_API_KEY });\n\nconst agent = new Agent({\n  name: 'Travel assistant',\n  instructions: 'You are a travel assistant.',\n});\n\nconst result = await run(agent, 'Can you find me a flight to Lisbon next month?', {\n  callModelInputFilter: createContextFilter(client, { identifier: 'user-123' }),\n});\n",[153,646,647,659,672,684,688,706,710,724,732,741,745,749,769,784],{"__ignoreMap":189},[193,648,649,651,653,655,657],{"class":195,"line":196},[193,650,273],{"class":272},[193,652,277],{"class":276},[193,654,280],{"class":272},[193,656,283],{"class":202},[193,658,286],{"class":276},[193,660,661,663,666,668,670],{"class":195,"line":289},[193,662,273],{"class":272},[193,664,665],{"class":276}," { createContextFilter } ",[193,667,280],{"class":272},[193,669,299],{"class":202},[193,671,286],{"class":276},[193,673,674,676,678,680,682],{"class":195,"line":304},[193,675,273],{"class":272},[193,677,309],{"class":276},[193,679,280],{"class":272},[193,681,314],{"class":202},[193,683,286],{"class":276},[193,685,686],{"class":195,"line":319},[193,687,323],{"emptyLinePlaceholder":322},[193,689,690,692,694,696,698,700,702,704],{"class":195,"line":326},[193,691,329],{"class":272},[193,693,333],{"class":332},[193,695,336],{"class":272},[193,697,339],{"class":272},[193,699,343],{"class":342},[193,701,346],{"class":276},[193,703,349],{"class":332},[193,705,352],{"class":276},[193,707,708],{"class":195,"line":355},[193,709,323],{"emptyLinePlaceholder":322},[193,711,712,714,716,718,720,722],{"class":195,"line":384},[193,713,329],{"class":272},[193,715,458],{"class":332},[193,717,336],{"class":272},[193,719,339],{"class":272},[193,721,465],{"class":342},[193,723,381],{"class":276},[193,725,726,728,730],{"class":195,"line":390},[193,727,405],{"class":276},[193,729,475],{"class":202},[193,731,399],{"class":276},[193,733,734,736,739],{"class":195,"line":402},[193,735,483],{"class":276},[193,737,738],{"class":202},"'You are a travel assistant.'",[193,740,399],{"class":276},[193,742,743],{"class":195,"line":413},[193,744,445],{"class":276},[193,746,747],{"class":195,"line":442},[193,748,323],{"emptyLinePlaceholder":322},[193,750,751,753,755,757,759,761,763,766],{"class":195,"line":448},[193,752,329],{"class":272},[193,754,512],{"class":332},[193,756,336],{"class":272},[193,758,517],{"class":272},[193,760,520],{"class":342},[193,762,523],{"class":276},[193,764,765],{"class":202},"'Can you find me a flight to Lisbon next month?'",[193,767,768],{"class":276},", {\n",[193,770,771,774,776,779,781],{"class":195,"line":453},[193,772,773],{"class":276},"  callModelInputFilter: ",[193,775,625],{"class":342},[193,777,778],{"class":276},"(client, { identifier: ",[193,780,396],{"class":202},[193,782,783],{"class":276}," }),\n",[193,785,786],{"class":195,"line":470},[193,787,445],{"class":276},[150,789,790],{},"It takes:",[540,792,793,801,818],{},[543,794,795,800],{},[169,796,797,549],{},[153,798,799],{},"identifier"," Whose memory to read.",[543,802,803,811,812,814,815,549],{},[169,804,805,366,807,366,809,549],{},[153,806,596],{},[153,808,600],{},[153,810,604],{}," Optional; the same search options as ",[153,813,260],{},", see ",[158,816,817],{"href":71},"API reference > Context",[543,819,820,825,826,829,830,833],{},[169,821,822,549],{},[153,823,824],{},"template"," Optional ",[153,827,828],{},"(context, instructions) => string","; the default appends a ",[153,831,832],{},"## Context from memory"," heading and the context lines to the agent's instructions.",[617,835,836],{},[150,837,838],{},"Turns with no user message, and turns where nothing relevant is found or the request fails, reach the model with the instructions unchanged. Errors are not thrown.",[174,840,842],{"id":841},"withcontext","withContext",[150,844,845,847,848,851],{},[153,846,842],{}," calls ",[153,849,850],{},"client.context"," and returns an instructions string with the context appended, for when you build the instructions yourself.",[183,853,855],{"className":263,"code":854,"language":265,"meta":189,"style":189},"import { withContext } from '@neurophic/openai-agents';\n\nconst userMessage = 'Can you find me a flight to Lisbon next month?';\n\nconst instructions = await withContext(client, {\n  identifier: 'user-123',\n  query: userMessage,\n  instructions: 'You are a travel assistant.',\n});\n",[153,856,857,870,874,888,892,909,917,922,930],{"__ignoreMap":189},[193,858,859,861,864,866,868],{"class":195,"line":196},[193,860,273],{"class":272},[193,862,863],{"class":276}," { withContext } ",[193,865,280],{"class":272},[193,867,299],{"class":202},[193,869,286],{"class":276},[193,871,872],{"class":195,"line":289},[193,873,323],{"emptyLinePlaceholder":322},[193,875,876,878,881,883,886],{"class":195,"line":304},[193,877,329],{"class":272},[193,879,880],{"class":332}," userMessage",[193,882,336],{"class":272},[193,884,885],{"class":202}," 'Can you find me a flight to Lisbon next month?'",[193,887,286],{"class":276},[193,889,890],{"class":195,"line":319},[193,891,323],{"emptyLinePlaceholder":322},[193,893,894,896,899,901,903,906],{"class":195,"line":326},[193,895,329],{"class":272},[193,897,898],{"class":332}," instructions",[193,900,336],{"class":272},[193,902,517],{"class":272},[193,904,905],{"class":342}," withContext",[193,907,908],{"class":276},"(client, {\n",[193,910,911,913,915],{"class":195,"line":355},[193,912,393],{"class":276},[193,914,396],{"class":202},[193,916,399],{"class":276},[193,918,919],{"class":195,"line":384},[193,920,921],{"class":276},"  query: userMessage,\n",[193,923,924,926,928],{"class":195,"line":390},[193,925,483],{"class":276},[193,927,738],{"class":202},[193,929,399],{"class":276},[193,931,932],{"class":195,"line":402},[193,933,445],{"class":276},[150,935,936],{},"With the default template, the returned string is:",[183,938,942],{"className":939,"code":940,"language":941,"meta":189,"style":189},"language-md shiki shiki-themes github-dark-default","You are a travel assistant.\n\n## Context from memory\n- Prefers window seats on long flights. (memory)\n","md",[153,943,944,949,953,959],{"__ignoreMap":189},[193,945,946],{"class":195,"line":196},[193,947,948],{"class":276},"You are a travel assistant.\n",[193,950,951],{"class":195,"line":289},[193,952,323],{"emptyLinePlaceholder":322},[193,954,955],{"class":195,"line":304},[193,956,958],{"class":957},"sp6Gy","## Context from memory\n",[193,960,961,964],{"class":195,"line":319},[193,962,963],{"class":199},"-",[193,965,966],{"class":276}," Prefers window seats on long flights. (memory)\n",[150,968,969,970,972,973,567,976,978,979,366,981,567,983,985],{},"It takes ",[153,971,566],{},", an optional ",[153,974,975],{},"instructions",[153,977,824],{},", and the same ",[153,980,596],{},[153,982,600],{},[153,984,604],{},". Like the filter, it returns the instructions unchanged when nothing is relevant or the request fails.",[150,987,988,989,549],{},"Learn more under ",[158,990,817],{"href":71},[992,993,994],"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 .sc3cj, html code.shiki .sc3cj{--shiki-default:#D2A8FF}html pre.shiki code .sp6Gy, html code.shiki .sp6Gy{--shiki-default:#79C0FF;--shiki-default-font-weight:bold}",{"title":189,"searchDepth":196,"depth":289,"links":996},[997,998,999,1000],{"id":176,"depth":289,"text":177},{"id":259,"depth":289,"text":260},{"id":624,"depth":289,"text":625},{"id":841,"depth":289,"text":842},"Give an OpenAI Agents SDK agent memory with ready-made tools and per-turn context",null,{},{"title":133},{"title":133,"description":1001},"abk5UcbuSo5r5ICY8Oxgv6bsonrmyxWkjcdVJXnWinw",[1008,1010],{"title":129,"path":130,"stem":131,"description":1009,"children":-1},"Give a Vercel AI SDK model memory with ready-made tools and prompt context",{"title":137,"path":138,"stem":139,"description":1011,"children":-1},"Add memory to a Laravel app with a facade, per-user scoping and Laravel AI SDK tools",1796467715068]