Search for and run AI models on Sunra.ai. Discover models, create video, image, and 3D model content, track their status, and manage the generated media.
This repository contains the official client libraries for sunra.ai, a platform for deploying and running AI models. The libraries provide robust and user-friendly interfaces for integrating sunra.ai endpoints into your applications across multiple programming languages.
clients/python/
sunra-client
(PyPI)pip install sunra-client
clients/javascript/
@sunra/client
(npm)npm install @sunra/client
clients/java/
ai.sunra.client:sunra-client
(Maven Central)implementation "ai.sunra.client:sunra-client:0.1.6"
Before using any client library, you'll need to:
export SUNRA_KEY=your-api-key
import sunra_client
# Simple synchronous call
result = sunra_client.subscribe(
"black-forest-labs/flux-kontext-pro/text-to-image",
arguments={"prompt": "a cute cat, realistic, orange"}
)
print(result["images"][0]["url"])
# Asynchronous call
async def main():
result = await sunra_client.subscribe_async(
"black-forest-labs/flux-kontext-pro/text-to-image",
arguments={"prompt": "a cute cat, realistic, orange"}
)
print(result["images"][0]["url"])
import { createSunraClient } from "@sunra/client";
const sunra = createSunraClient({
credentials: process.env.SUNRA_KEY,
});
const result = await sunra.subscribe(
"black-forest-labs/flux-kontext-pro/text-to-image",
{
input: {
prompt: "a cute cat, realistic, orange"
}
}
);
console.log(result.images[0].url);
import ai.sunra.client.*;
var sunra = SunraClient.withEnvCredentials();
var result = sunra.subscribe(
"black-forest-labs/flux-kontext-pro/text-to-image",
SubscribeOptions.<JsonObject>builder()
.input(Map.of("prompt", "a cute cat, realistic, orange"))
.resultType(JsonObject.class)
.build()
);
System.out.println(result.getData());
For client-side applications, we provide a server proxy to securely handle API calls without exposing your credentials. Available for popular frameworks:
server-proxy/
@sunra/server-proxy
(npm)The MCP server provides a universal interface for AI model tools, enabling seamless integration with modern code assistants and IDEs such as Cursor and Claude Desktop. It acts as a bridge between Sunra.ai and your development environment, exposing Sunra's models and tools via the Model Context Protocol.
Why use the MCP server?
npx @sunra/mcp-server --transport http --port 3925
.cursor/mcp.json
:{
"mcpServers": {
"sunra-mcp-server": {
"url": "http://localhost:3925/sse"
}
}
}
export SUNRA_KEY="your-api-key-here"
sunra-mcp-server
and use tools like list-models
, model-schema
, etc.npx @sunra/mcp-server
npx @sunra/mcp-server
SUNRA_KEY=your-api-key-here
sunra-mcp-server
and use the available tools.mcp-server/README.md
for full tool list, development, and troubleshooting.The repository includes comprehensive examples for different frameworks and use cases:
examples/demo-nextjs-app-router/
and examples/demo-nextjs-page-router/
examples/demo-nodejs/
examples/demo-express-app/
examples/demo-java/
examples/demo-java-async/
examples/demo-kotlin/
examples/demo-python/
To set up the development environment:
pnpm i -r
export SUNRA_KEY=your-api-key
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
npm install
git checkout -b feat/add-cool-thing
) or a bugfix branch (git checkout -b fix/smash-that-bug
)git commit -m 'feat(client): added a cool thing'
) - use conventional commitsgit push --set-upstream origin feat/add-cool-thing
)Check the good first issue queue, your contribution will be welcome!
Distributed under the Apache 2.0 License. See LICENSE for more information.
This project is derived from:
and adapted to work with sunra.ai. The original projects are licensed under the MIT/Apache 2.0 License. We extend our gratitude to the original authors for their contributions.