An open API service indexing awesome lists of open source software.

https://github.com/AoElite/claude4j

A very simple java library to interact with Claude's API
https://github.com/AoElite/claude4j

anthropic anthropic-claude claude claude-3 claude-ai claude-api java library

Last synced: 5 months ago
JSON representation

A very simple java library to interact with Claude's API

Awesome Lists containing this project

README

          

> [!WARNING]
> **This repository is being archived. Please use Anthropic's official Java SDK instead.**
> https://github.com/anthropics/anthropic-sdk-java

A very simple java library to interact with Claude's API

Example usage:
```java
ClaudeAPI client = new ClaudeClient(System.getenv("CLAUDE_API_KEY"));

ClaudeResponse response = client.sendRequest(ClaudeRequest.builder()
.model(ClaudeAIModel.HAIKU_3_5)
.max_tokens(100)
.temperature(0)
.stop_sequence("###")
.system("You are a AI math assistant")
.input(ClaudeRole.USER.text("what's 2+2?"))
.input(ClaudeRole.ASSISTANT.text("4"))
.input(ClaudeRole.USER.text("what's 3+3?"))
.build());

if (response != null) { // response could timeout
for (String string : response.getContent()) {
System.out.println(string);
}
}
```

You can create a API key [here](https://console.anthropic.com/settings/keys) once you have created a Anthropic account.

TODO:
- [X] Image/File support
- [ ] Stream support
- [ ] Embeddings
- [ ] Legacy models
- [ ] Cache support