Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Delivering APIs for AI

Z
December 04, 2024

Delivering APIs for AI

My talk for 2024 APIDays Paris https://www.apidays.global/paris/.
Follow up to my 2024 Nordic APIs platform summit talk, this time more hands on. https://speakerdeck.com/zdne/apis-for-ai-have-we-failed

Z

December 04, 2024
Tweet

More Decks by Z

Other Decks in Technology

Transcript

  1. APIs for AI How to deliver APIs for Agentic AI

    Zdeněk “Z” Němec, superface.ai, December ’24
  2. Zdeněk “Z” Němec • designed an API description language •

    pioneered API-design & API-first • built APIs with the largest enterprises • building API infrastructure for AI agents • building AI agents Founder and CTO of Superface.ai • DSL director Apiary.io → Oracle • Founder of Good API consulting • Enterprise API strategy and execution superface.ai
  3. Three levels of AI maturity Current business drivers for AI

    are “safe”: Assisting and augmenting workforce superface.ai
  4. Agentic AI LLM-powered agents • An agent is a software

    that acts on behalf of user or another program • LLM-powered agents can independently • make decisions • perform tasks • interact with other systems • Agent needs tools to be able to do meaningful things superface.ai
  5. Tools Used by agents • Agents are only as good

    as the tools they have • computation • databases • API calls • LLM works more like a human • It’s able to fi gure out what endpoints to call from API documentation • Agents are more resilient to API changes LLM-powered Agent Memory Planning Tools APIs superface.ai
  6. In many situations it is easier, faster and cheaper to

    access data and perform actions via UI over API. Often, it is the only way. superface.ai
  7. LinkedIn A minute vs. several weeks • LinkedIn API exists

    • It is not easily accessible to developers • The functionality is limited • Using 3rd party (scraping) service • Connect my agent to LinkedIn in one minute superface.ai
  8. Accessing a Salesforce instance of a biggest HW maker Deal

    or no deal • Entering data into CRM • The case was saving 38hrs / week • Agent did not get the API access to the CRM • Entering the data using web actor (scraper) works superface.ai
  9. There are many more similar stories • No access to

    API for agent developers • Legacy APIs (WS/RPC) • API can do only fraction of what UI can superface.ai
  10. LLM function calling • Mechanism that LLM uses to recognize

    a and call a function (tool) • Ideally, we would give an API to LLM and it would fi gure it out • The more atomic and abstract the API is the harder it is to use LLM detects function requirements Structured function input Execution of the function Returning the result API call LLM function calling repeat multiple times superface.ai
  11. Documentation Use descriptions to control and hint the LLM: •

    to pick the tool • what others tools to call • instruct to use fi lters • describe out-of-the-band knowledge Describe everything Example: Salesforce CRM superface.ai
  12. Less is more • Return only what is necessary •

    GraphQL shines here! • Bundle API calls • when descriptions are not enough or context would be too big • Create endpoints to serve speci fi c agentic use-cases • also helps for weaker LLMs Mind the Context Size Example: Google Mail superface.ai
  13. Flat parameters are better • Nesting is hard for LLMs

    • More complex objects can be tough for LLM to correctly fi ll Minimize nesting Example: Google Sheets superface.ai
  14. • If your API is abstract agent developers needs to

    design their tool interfaces • LLM will not fi gure it out Avoid abstraction Extremely di ff i cult for LLMs Example: Notion Notion API: you need to get the database, then blocks in the database, and then iterate through the blocks superface.ai
  15. • Return messages relevant to actual error • APIs error

    handling often sucks • Respect status codes • Most agents can use error message to fi x the request (in 400 cases) • Good error messages are the di ff erence between a failure and success Error handling design it to be useful superface.ai
  16. • To prevent hallucinations • Tools need to communicate any

    relations between parameters • Ideally using JSON Schema (and not description) • Correctly named, described, including format (e.g. timestamps), and default values • De fi ne parameters as enums where possible Required fields must be designed well Example: Scrapin superface.ai
  17. • Can take away attention from required fi elds •

    Not a concern when you are working with one tool Optional fields avoid too many Example: Google Maps superface.ai
  18. • Custom GPT limit is 30 • We think the

    sweet spot is only 15-20 • We are are using hierarchy to fi lter hundreds of tools • Isolated agent can help select the right tool Number of tools keep it very, very low superface.ai
  19. What it means for your API? • Follow conventions, don’t

    get too creative • Keep it simple • Focus on documentation, description and naming • Streamline API access: OIDC/OAuth is a must • Have API AI PO: API- fi rst, API Design for AI superface.ai
  20. APIs are built for the old world • Agents are

    your new best friends • As API provider / product owner go out and look • The API consumption will be 80% agents and 20% humans superface.ai
  21. Get APIs right or people will either use UI or

    walk away. ( and agents ) superface.ai
  22. Thank you! Let’s talk Zdenek “Z” Nemec 
 Twitter/X: @zdne

    LinkedIn: https://www.linkedin.com/in/zdne/ superface.ai superface.ai