sunra.ai 客户端库 logo

sunra.ai 客户端库

Organization
sunra-ai

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…

Publishersunra-ai
Repositorysunra-clients
LanguageTypeScript
Forks
0
Stars
7
Available tools
10
Transport typestdio, streamable-http
Categories
LicenseApache-2.0
Links
  • Connect tools to AI workflows

    sunra.ai 客户端库 exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 10 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    7 stars and 0 forks from the linked repository.

sunra.ai Client Libraries

English | 简体中文

License @sunra/client npm package PyPI - Version Maven Central Version Discord

About the Project

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.

Available Client Libraries

🐍 Python Client

  • Location: clients/python/
  • Package: sunra-client (PyPI)
  • Features: Synchronous and asynchronous support, streaming responses, file uploads
  • Installation: pip install sunra-client

📦 JavaScript/TypeScript Client

  • Location: clients/javascript/
  • Package: @sunra/client (npm)
  • Features: Works in Web, Node.js, and React Native environments
  • Installation: npm install @sunra/client

☕ Java Client

  • Location: clients/java/
  • Package: ai.sunra.client:sunra-client (Maven Central)
  • Features: Synchronous, asynchronous, and Kotlin coroutine support
  • Installation: implementation "ai.sunra.client:sunra-client:0.1.6"

Quick Start

Before using any client library, you'll need to:

  1. Sign up at sunra.ai
  2. Get your API key from the dashboard
  3. Set your API key as an environment variable: export SUNRA_KEY=your-api-key

Python Example

python
import sunra_client

# Simple synchronous call
result = sunra_client.subscribe(
    "openai/gpt-image-2/text-to-image",
    arguments={"prompt": "a cute cat, realistic, orange", "quality": "high"}
)
print(result["images"][0]["url"])

# Asynchronous call
async def main():
    result = await sunra_client.subscribe_async(
        "openai/gpt-image-2/text-to-image",
        arguments={"prompt": "a cute cat, realistic, orange", "quality": "high"}
    )
    print(result["images"][0]["url"])

JavaScript Example

typescript
import { createSunraClient } from "@sunra/client";

const sunra = createSunraClient({
  credentials: process.env.SUNRA_KEY,
});

const result = await sunra.subscribe("openai/gpt-image-2/text-to-image", {
  input: {
    prompt: "a cute cat, realistic, orange",
    quality: "high",
  },
});
console.log(result.images[0].url);

LLM APIs

Sunra's LLM endpoints are compatible with the standard OpenAI and Anthropic API formats. Use the corresponding official SDK with https://api-llm.sunra.ai/v1 as the base URL; a separate Sunra LLM package is not required.

javascript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.SUNRA_KEY,
  baseURL: "https://api-llm.sunra.ai/v1",
});

const completion = await client.chat.completions.create({
  model: "google/gemini-2.5-flash",
  messages: [{ role: "user", content: "Hello" }],
  provider: { only: ["google-vertexai"] },
});

Omit provider to use automatic routing. See the LLM documentation and the runnable Node.js and Python examples in this repository.

Java Example

java
import ai.sunra.client.*;

var sunra = SunraClient.withEnvCredentials();

var result = sunra.subscribe(
    "openai/gpt-image-2/text-to-image",
    SubscribeOptions.<JsonObject>builder()
        .input(Map.of(
            "prompt", "a cute cat, realistic, orange",
            "quality", "high"
        ))
        .resultType(JsonObject.class)
        .build()
);
System.out.println(result.getData());

Server Proxy

For client-side applications, we provide a server proxy to securely handle API calls without exposing your credentials. Available for popular frameworks:

  • Location: server-proxy/
  • Package: @sunra/server-proxy (npm)
  • Supports: Next.js, Express, Hono, Remix, SvelteKit

MCP Server (Model Context Protocol)

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?

  • Enables code assistants (like Cursor, Claude, etc.) to access Sunra models and tools directly from your editor
  • Supports listing models, fetching schemas, submitting jobs, streaming results, and more
  • Secure: API keys are managed via environment variables or runtime configuration
  • No need to write glue code—just run the server and connect your tool

Quick Start

1. Install & Run (no local build needed)

bash
npx @sunra/mcp-server --transport http --port 3925

2. For Cursor IDE

  • Add to your .cursor/mcp.json:
json
{
  "mcpServers": {
    "sunra-mcp-server": {
      "url": "http://localhost:3925/sse"
    }
  }
}
  • Set your API key:
    bash
    export SUNRA_KEY="your-api-key-here"
  • In Cursor, select the sunra-mcp-server and use tools like list-models, model-schema, etc.

3. For Claude Desktop (Anthropic)

  • Start the server in stdio mode (default):
    bash
    npx @sunra/mcp-server
  • In Claude Desktop settings, add a new MCP server:
    • Type: Local executable
    • Command: npx @sunra/mcp-server
    • Environment Variables:
      SUNRA_KEY=your-api-key-here
  • In Claude, select the sunra-mcp-server and use the available tools.

4. Advanced Usage & Documentation

Examples

The repository includes comprehensive examples for different frameworks and use cases:

Development

To set up the development environment:

  1. Clone the repository
  2. Install dependencies: pnpm i -r
  3. Set up your API key: export SUNRA_KEY=your-api-key
  4. Run examples or tests as needed

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Make sure you read our Code of Conduct
  2. Fork the project and clone your fork
  3. Setup the local environment with npm install
  4. Create a feature branch (git checkout -b feat/add-cool-thing) or a bugfix branch (git checkout -b fix/smash-that-bug)
  5. Commit the changes (git commit -m 'feat(client): added a cool thing') - use conventional commits
  6. Push to the branch (git push --set-upstream origin feat/add-cool-thing)
  7. Open a Pull Request

Check the good first issue queue, your contribution will be welcome!

License

Distributed under the Apache 2.0 License. See LICENSE for more information.

Credits

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.

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "sunra-ai-sunra-clients": {
      "command": "npx",
      "args": [
        "-y",
        "sunra-clients"
      ]
    }
  }
}

Available Tools

  • submit

    Submit a request to the Sunra queue for processing

  • status

    Check the status of a request in the Sunra queue

  • result

    Retrieve the result of a completed request from the Sunra queue

  • cancel

    Cancel a request in the Sunra queue

  • subscribe

    Submit a request to the Sunra queue and wait for completion

  • set-sunra-key

    Set the Sunra API key for authenticating with the Sunra.ai service

  • upload

    Upload a file to Sunra storage and get back a URL

  • list-models

    List all available AI models from the Sunra API

  • search-models

    Search for AI models by keywords in their names, descriptions, or aliases

  • model-schema

    Get the input and output JSON schemas for a specific AI model endpoint from its OpenAPI specification

Use sunra.ai 客户端库 MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once sunra.ai 客户端库 is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. You can run MCP locally on your device or connect to a remote MCP server URL.

Option 1: Use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add sunra.ai 客户端库 as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the sunra.ai 客户端库 MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "sunra-ai-sunra-clients": {
      "command": "npx",
      "args": [
        "-y",
        "sunra-clients"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the sunra.ai 客户端库 MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the sunra.ai 客户端库 MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use sunra.ai 客户端库 to help me with this task?
sunra.ai 客户端库
Sure. I read it.
Here is what I found using sunra.ai 客户端库.

Option 2: Add an MCP server URL

Use this when sunra.ai 客户端库 is already hosted remotely or your team wants one shared connector that multiple users can access.

1

Open MCP connectors

In TypingMind, go to Plugins, open MCP connectors, then choose Add URL.

  1. Open TypingMind in your browser.
  2. Go to Plugins.
  3. Open MCP connectors.
  4. Click Add URL.
TypingMind Add Custom MCP Server URL form
2

Paste the server URL

Enter your server URL in the Server URL field. Add a connection name, description, icon, custom HTTP headers, or OAuth client settings if the server requires them.

  1. Paste your server URL into the Server URL field.
  2. Enter a connection name for sunra.ai 客户端库.
  3. Add a description and icon if you want it to be easier to identify.
  4. Add custom HTTP headers or OAuth client details if the server requires authentication.
3

Create the connection

Click Create connection, then return to the Plugins list and confirm the new MCP connection is active.

  1. Click Create connection.
  2. Return to the MCP connectors list.
  3. Confirm the sunra.ai 客户端库 connection appears as active.
  4. Refresh the plugin list if the connection does not appear immediately.
4

Switch models without reconnecting

Start a chat with your preferred model, enable the sunra.ai 客户端库 tools from Plugins, and switch to another model whenever needed. The MCP connection stays available to the TypingMind workspace.

  1. Start a new chat in TypingMind.
  2. Select the AI model you want to use.
  3. Enable the sunra.ai 客户端库 tools from Plugins.
  4. Ask the model to use the tool when needed.
  5. Switch to another AI model and reuse the same MCP connection.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use sunra.ai 客户端库 to help me with this task?
sunra.ai 客户端库
Sure. I read it.
Here is what I found using sunra.ai 客户端库.

Frequently asked questions

What is the sunra.ai 客户端库 MCP server used for?

sunra.ai 客户端库 is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use sunra.ai 客户端库 MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use sunra.ai 客户端库 with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use sunra.ai 客户端库 MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With sunra.ai 客户端库 connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect sunra.ai 客户端库 MCP to TypingMind?

sunra.ai 客户端库 can be connected in TypingMind with the local MCP connector or by adding a remote MCP server URL. Use the local connector when the server needs access to files, apps, or private resources on your device, and use a server URL when the MCP server is hosted remotely.

What tools does sunra.ai 客户端库 MCP provide in TypingMind?

sunra.ai 客户端库 exposes 10 MCP tools that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use sunra.ai 客户端库 MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If sunra.ai 客户端库 requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇