Skip to main content

AI SDK

Notes

  • Provider 模型抽象
  • LanguageModel
    • doGenerate
    • doStream
  • EmbeddingsModel
    • doEmbed
  • ImageModel
    • doGenerate
  • TranscriptionModel
    • doTranscribe
  • SpeechModel
    • doGenerate
  • RerankingModel
    • doRerank

Design

finish reasonopenai finish reasonanthropic stop reasongemini finish reason
stopstoppause_turn, end_turn, stop_sequence, tool_useSTOP(无工具调用)
lengthlengthmax_tokens, model_context_window_exceededMAX_TOKENS
content-filtercontent_filterrefusalIMAGE_SAFETY, RECITATION, SAFETY, BLOCKLIST, PROHIBITED_CONTENT, SPII
tool-callsfunction_call, tool_callstool_useSTOP(带工具调用)
error--MALFORMED_FUNCTION_CALL
otherothercompaction, otherFINISH_REASON_UNSPECIFIED, OTHER
tool choiceopenaianthropicgemini
auto'auto'{ type: 'auto' }mode: 'AUTO' / 'VALIDATED'
none'none'不支持(SDK 层面移除所有 tools 模拟)mode: 'NONE'
required'required'{ type: 'any' }mode: 'ANY' / 'VALIDATED'
tool{ type: 'function', function: { name } }{ type: 'tool', name }mode: 'ANY' (包含 allowedFunctionNames: [name]) / 'VALIDATED'