OapiCodemode (oapi_codemode v0.1.0)

Copy Markdown View Source

OpenAPI search-and-execute for LLM agents, Cloudflare-codemode style.

Drop in an OpenAPI spec; get two tools: search_apis (LLM-written JS filters the spec as data in a sandbox) and execute_api_code (LLM-written JS calls apis.<name>.request(), intercepted, validated against the spec, credentialed, and executed in Elixir). Credentials never enter the sandbox.

See docs/plans/2026-08-16-openapi-search-execute-design.md for the design.

Summary

Functions

Ingest a raw spec into an %Artifact{} for caching. See register/4.

Ingest a raw spec and register it in one call.

Register a pre-ingested artifact. Hosts that cache %Artifact{}s (ingest is pure) use this to skip re-parsing; ingest_and_register/4 remains the one-shot path.

Emit the search/execute tool definitions. See OapiCodemode.Tools.definitions/1.

Functions

ingest(raw_spec)

Ingest a raw spec into an %Artifact{} for caching. See register/4.

ingest_and_register(registry, name, raw_spec, config_opts \\ [])

Ingest a raw spec and register it in one call.

Returns {:error, {:invalid_config_option, key}} rather than raising when config_opts contains a key ApiConfig doesn't define (e.g. a typo'd option name) — a host building config from user/config-file input gets a value it can act on instead of a KeyError crash.

register(registry, name, artifact, config_opts \\ [])

Register a pre-ingested artifact. Hosts that cache %Artifact{}s (ingest is pure) use this to skip re-parsing; ingest_and_register/4 remains the one-shot path.

tools(opts)

Emit the search/execute tool definitions. See OapiCodemode.Tools.definitions/1.