Back to directory
softwaremill avatar

sttp-ai

Scala client for OpenAI, Claude, and compatible APIs. Read more below about its uses, features, and usage.

Clone repository

git clone https://github.com/softwaremill/sttp-ai.git

98

Stars

17

Forks

15

Watchers

Apache-2.0

License

sttp-ai

Ideas, suggestions, problems, questions CI

sttp.ai:core sttp.ai:openai sttp.ai:claude sttp.ai:gemini

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. Ollama, Grok, OpenRouter). Use the power of ChatGPT, Claude, and Gemini inside your code!

sttp-ai uses sttp client to describe requests and responses used in OpenAI, Claude (Anthropic), Gemini (Google), and OpenAI-compatible endpoints.

Documentation

Full documentation is available at sttp-ai.softwaremill.com.

Quickstart

For OpenAI/OpenAI-compatible APIs

Add the following dependency:

"com.softwaremill.sttp.ai" %% "openai" % "0.8.0"

For Claude (Anthropic) API

Add the following dependency:

"com.softwaremill.sttp.ai" %% "claude" % "0.8.0"

// For streaming support, add one or more (these modules are shared across OpenAI, Claude, and Gemini):
"com.softwaremill.sttp.ai" %% "fs2" % "0.8.0"    // cats-effect/fs2
"com.softwaremill.sttp.ai" %% "zio" % "0.8.0"    // ZIO
"com.softwaremill.sttp.ai" %% "akka" % "0.8.0"   // Akka Streams (Scala 2.13 only)
"com.softwaremill.sttp.ai" %% "pekko" % "0.8.0"  // Pekko Streams
"com.softwaremill.sttp.ai" %% "ox" % "0.8.0"    // Ox direct-style (Scala 3 only)

For Gemini (Google) API

Add the following dependency:

"com.softwaremill.sttp.ai" %% "gemini" % "0.8.0"

// For streaming support, add one or more (these modules are shared across OpenAI, Claude, and Gemini):
"com.softwaremill.sttp.ai" %% "fs2" % "0.8.0"    // cats-effect/fs2
"com.softwaremill.sttp.ai" %% "zio" % "0.8.0"    // ZIO
"com.softwaremill.sttp.ai" %% "akka" % "0.8.0"   // Akka Streams (Scala 2.13 only)
"com.softwaremill.sttp.ai" %% "pekko" % "0.8.0"  // Pekko Streams
"com.softwaremill.sttp.ai" %% "ox" % "0.8.0"    // Ox direct-style (Scala 3 only)

sttp-openai is available for Scala 2.13 and Scala 3

Then head to the documentation for usage examples: OpenAI, Claude, and Gemini clients, streaming, structured outputs, tool calling, and the agent loop — plus the agent-testkit module for testing agents without calling a paid API.

Contributing

If you have a question, or hit a problem, feel free to post on our community https://softwaremill.community/c/open-source/

Or, if you encounter a bug, something is unclear in the code or documentation, don't hesitate and open an issue on GitHub.

For running integration tests against the real OpenAI API, see Integration Testing Guide.

Commercial Support

We offer commercial support for sttp and related technologies, as well as development services. Contact us to learn more about our offer!

Copyright (C) 2023-2025 SoftwareMill https://softwaremill.com.

Releases

What’s Changed

Feature/agent interceptor (#574) @flsh86

What’s Changed

Feature/capability tagged models (#570) @flsh86 Bump VirtusLab/scala-cli-setup from 1.15.0 to 1.16.0 (#572) @dependabot[bot] Bump release-drafter/release-drafter from 7.6.0 to 7.7.0 (#...

What’s Changed

Feature/timeout retries (#560) @flsh86 Feature/reasoning content (#552) @flsh86 Azure OpenAI support (#551) @flsh86 Bump sbt/setup-sbt from 1.5.2 to 1.5.4 (#549) @dependabot[bot]

Depe...

Jul 29, 2026

Download .zip

What’s Changed

Docs/04 claude gemini agents (#547) @flsh86, @claude Docs/03 OpenAI (#546) @flsh86, @claude Docs/02 schemas (#545) @flsh86, @claude Docs/01 foundation (#544) @flsh86, @claude Gemini/05...

Jul 27, 2026

Download .zip

What’s Changed

Handle MaxIterations/TokenLimit gracefully in Agent.runAs (#534) @flsh86 No tools final iteration (#529) @flsh86 Worktree extra body support (#525) @flsh86 Bump release-drafter/release...