sttp-ai: Scala client for OpenAI, Claude, Gemini, and compatible APIs
sttp is a family of Scala HTTP-related projects, and currently includes:
sttp client: the Scala HTTP client you always wanted!
sttp tapir: typed API descriptions
sttp ai: this project. Non-official Scala client wrapper for OpenAI, Claude (Anthropic), Gemini (Google), and OpenAI-compatible APIs (e.g. Azure OpenAI, Ollama, Grok, Groq, OpenRouter). Use the power of ChatGPT, Claude, and Gemini inside your code!
sttp-ai uses sttp client to describe requests and responses as plain, type-safe Scala values — request bodies, response models, JSON schemas, and tool definitions are all derived from case classes via Tapir and circe, with minimal ceremony and no hand-written JSON.
What can you do with sttp-ai?
Call model APIs directly — OpenAI (chat completions, embeddings, audio, images, and more), Claude (Messages API), and Gemini (Interactions API); each provider has a blocking sync client and a raw-request async client that works with any effect system
Use OpenAI-compatible providers — Azure OpenAI, Ollama, Grok, Groq, OpenRouter, vLLM and others via the OpenAI client with a custom base URL
Stream responses — server-sent events streaming for fs2, ZIO, Akka Streams, Pekko Streams, and Ox
Get structured outputs — JSON-schema-constrained responses parsed straight into your case classes (OpenAI, Claude, Gemini)
Call tools — let the model invoke functions in your code (OpenAI, Claude, Gemini)
Run an agent loop — autonomous tool-calling agents with typed tools and typed results, working across all three providers, with tools loadable from MCP servers, testable offline with the agent testkit
Why sttp-ai?
sttp-ai implements the native APIs of all three major providers — OpenAI, Claude, and Gemini — in one library, rather than funnelling everything through an OpenAI-compatibility shim. You bring your own effect system: cats-effect, ZIO, Akka/Pekko Streams, direct-style Ox, or plain blocking calls. Structured-output schemas and tool definitions are derived from case classes instead of written by hand, and the built-in agent loop gives you typed tools and typed results, with tools loadable from MCP servers. Cross-built for Scala 2.12, 2.13 and Scala 3, with Scala Native support (Scala 3) for the core and provider modules.
Getting started
OpenAI
Claude