why anthropic web search not works?

前情提要 為什麼我明明就有設定要使用web search tool,但查詢出來的結果就是舊的資料呢? 在使用ai api很常會使用到的tool有兩個,一個是web search,另一個是structured outputs,也就是將你的結果變成程式看得懂的格式,讓程式比較好處理 舉例來說,我是一個加密貨幣的平台,我希望可以顯示跟比特幣相關的新聞,讓使用者可以瀏覽.這時我可以使用ai api,請他幫我取得最新10筆有關比特幣的文章,且幫我轉成我指定的json格式,這樣前端就可以直接拿來使用了 node.js example code如下 const message = await anthropic.messages.create({ model: "claude-sonnet-3", max_tokens: 4096, messages: [ { role: "user", content: "give me the latest 10 news about bitcoins", }, ], tools: [ { type: "web_search_20250305", name: "web_search", max_uses: 5, }, { name: "article_format", description: "Provide the article info with url and title", input_schema: { type: "object", properties: { url: { type: "string", description:"The article resource url", }, title: { type: "string", description:"The article title", } }, required: ["url", "title"], }, }, ], tool_choice: { type: "tool", name: "article_format", }, temperature: 0.3, }); 問題說明 我希望ai回傳的資料一定要是特定的資料結構,所以我設定了tool_choice來確article_format他一定會執行,的確資料都有正確被format,但問題來了,結果web search沒反應了,該怎麼辦? ...

October 21, 2025 · 1 min

OpenAI API 取得免費Token

如果想要玩open api,但又不想要一開始就付那麼多錢,可以參考以下的文章,一起當個快樂的免費仔吧😂 如何取得免費token 如果想要免費取得額度測試OpenAI API,可以參考以下的步驟 購買credit [link]:必須先購買credi才有使用api的權限,最少可以只買5美元,但要額外再付國外手續費 Enable 與平台共享資料:預設會是disabled,api查詢的資料預設不會作為訓練模型的內容,你可以選擇Enabled全部的project還是部分的project,可以指enabled沒有太多機敏資料的project 主要是enabled這項 Share inputs and outputs with OpenAI,可以獲得每日共享token,輕量的模型,每天有250萬的token可以使用,標準的模式,每天有25萬的token可以使用 You're eligible for free daily usage on traffic shared with OpenAI. Up to 250 thousand tokens per day across gpt-5, gpt-5-chat-latest, gpt-4.1, gpt-4o, o1 and o3 Up to 2.5 million tokens per day across gpt-5-mini, gpt-5-nano, gpt-4.1-mini, gpt-4.1-nano, gpt-4o-mini, o1-mini, o3-mini, o4-mini, and codex-mini-latest. 更多的規則以及詳細資料可以參考 [link] 如果看不到Data controls的選項能是還沒儲值,要儲值之後才看得到 3 .開始使用open ai api ...

August 27, 2025 · 1 min