Logo: sunra.ai 客户端库

sunra.ai 客户端库

Organisatioun
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…

Editeursunra-ai
Repositorysunra-clients
SproochTypeScript
Forks
0
Stären
7
Disponibel Tools
10
Transporttypstdio, streamable-http
Kategorien
LizenzApache-2.0
Linken
  • Tools mat KI-Workflows verbannen

    sunra.ai 客户端库 bitt MCP-Funktiounen un, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • Disponibel Tools: 10

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an deem MCP-Client ze konfiguréieren, deen Dir am léifste benotzt.

  • Interessi vun der Communautéit um Open-Source-Projet

    Zuele vum verlinkte Repository – Stären: 7, Forks: 0.

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.

Installatioun

TypingMind
Viraussetzungen:

Node.js 18+

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

Disponibel 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

sunra.ai 客户端库 MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal sunra.ai 客户端库 verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dir kënnt MCP lokal op Ärem Apparat ausféieren oder Iech iwwer d'URL mat engem externen MCP-Server verbannen.

Optioun 1: De lokale Connector benotzen

Benotzt dës Optioun, wann den MCP-Server Zougrëff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „Dësen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector: D'Optioun „Dësen Apparat“ ass ausgewielt
2

De Connector-Befeel ausféieren

Wielt „Dësen Apparat“, kopéiert de Befeel aus TypingMind a féiert en am Terminal aus. Loosst de Prozess lafen, wärend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Setzt de kopéierte Befeel an a féiert en aus.
  4. Bestätegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wärend Dir MCP-Tools benotzt.
3

sunra.ai 客户端库 als Server derbäisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren änneren“ a setzt d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren änneren“.
  3. Setzt d'MCP-Serverkonfiguratioun fir sunra.ai 客户端库 an.
  4. Späichert d'Serverlëscht.
  5. Aktualiséiert d'Säit, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem Knäppchen „Serveren änneren“
{
  "mcpServers": {
    "sunra-ai-sunra-clients": {
      "command": "npx",
      "args": [
        "-y",
        "sunra-clients"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

Späichert d'Serverlëscht, maacht „Plugins“ op an aktivéiert d'MCP-Tools vun der Integratioun sunra.ai 客户端库. Wielt dann e belibegen ënnerstëtzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'Säit „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vun der Integratioun sunra.ai 客户端库.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierten MCP-Tools an engem ausgewielte KI-Modell
Kënnt Dir mir mat sunra.ai 客户端库 bei dëser Aufgab hëllefen?
sunra.ai 客户端库
Jo. Ech hunn et gelies.
Dat hunn ech mat sunra.ai 客户端库 fonnt.

Optioun 2: Eng MCP-Server-URL derbäisetzen

Benotzt dës Optioun, wann sunra.ai 客户端库 schonn op engem externe Server gehost gëtt oder Är Ekipp ee gemeinsame Connector wëllt, op dee méi Benotzer kënne zougräifen.

1

MCP-Connectoren opmaachen

Gitt an TypingMind op „Plugins“, maacht „MCP-Connectoren“ op a wielt dann „URL derbäisetzen“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Gitt op „Plugins“.
  3. Maacht „MCP-Connectoren“ op.
  4. Klickt op „URL derbäisetzen“.
TypingMind-Formulaire, fir eng benotzerdefinéiert MCP-Server-URL derbäizesetzen
2

Déi kopéiert Server-URL asetzen

Gitt Är Server-URL am Feld „Server-URL“ an. Setzt e Verbindungsnumm, eng Beschreiwung, e Symbol, benotzerdefinéiert HTTP-Headeren oder OAuth-Clientastellungen derbäi, wann de Server se erfuerdert.

  1. Setzt Är Server-URL an d'Feld „Server-URL“ an.
  2. Gitt en Numm fir d'Verbindung mat sunra.ai 客户端库 an.
  3. Wann Dir d'Verbindung méi einfach erëmerkenne wëllt, setzt eng Beschreiwung an e Symbol derbäi.
  4. Setzt benotzerdefinéiert HTTP-Headeren oder OAuth-Clientdetailer derbäi, wann de Server eng Authentifizéierung erfuerdert.
3

D'Verbindung erstellen

Klickt op „Verbindung erstellen“, gitt dann zeréck op d'Plugin-Lëscht a kontrolléiert, ob déi nei MCP-Verbindung aktiv ass.

  1. Klickt op „Verbindung erstellen“.
  2. Gitt zeréck op d'Lëscht vun de MCP-Connectoren.
  3. Kontrolléiert, ob d'Verbindung mat sunra.ai 客户端库 als aktiv ugewise gëtt.
  4. Aktualiséiert d'Plugin-Lëscht, wann d'Verbindung net direkt ugewise gëtt.
4

Modeller wiesselen, ouni MCP nei ze verbannen

Start e Chat mat Ärem bevorzugte Modell, aktivéiert d'Tools vun der Integratioun sunra.ai 客户端库 ënner „Plugins“ a wiesselt bei Bedarf op en anere Modell. D'MCP-Verbindung bleift am TypingMind-Aarbechtsberäich disponibel.

  1. Start en neie Chat an TypingMind.
  2. Wielt de KI-Modell, deen Dir benotze wëllt.
  3. Aktivéiert d'Tools vun der Integratioun sunra.ai 客户端库 ënner „Plugins“.
  4. Biet de Modell, d'Tool ze benotzen, wann néideg.
  5. Wiesselt op en anere KI-Modell a benotzt déiselwecht MCP-Verbindung weider.
TypingMind-Chat mat aktivéierten MCP-Tools an engem ausgewielte KI-Modell
Kënnt Dir mir mat sunra.ai 客户端库 bei dëser Aufgab hëllefen?
sunra.ai 客户端库
Jo. Ech hunn et gelies.
Dat hunn ech mat sunra.ai 客户端库 fonnt.

Heefeg gestallte Froen

Fir wat gëtt den MCP-Server sunra.ai 客户端库 benotzt?

sunra.ai 客户端库 ass en MCP-Server, deen et kompatibele KI-Clienten erlaabt, op extern Tools a Kontextinformatioune zouzegräifen. An TypingMind kënnt Dir dësen MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech sunra.ai 客户端库 MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir sunra.ai 客户端库 mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni den MCP-Server fir all Modell separat anzeriichten.

Firwat sunra.ai 客户端库 MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann sunra.ai 客户端库 verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Ären Aarbechtsoflaf beim Chatten an TypingMind organiséieren.

Wéi verbannen ech sunra.ai 客户端库 MCP mat TypingMind?

Dir kënnt sunra.ai 客户端库 iwwer de lokale MCP-Connector oder iwwer d'URL vun engem Remote-MCP-Server mat TypingMind verbannen. Benotzt de lokale Connector, wann de Server Zougrëff op Fichieren, Apps oder privat Ressourcen op Ärem Apparat brauch, an eng Server-URL, wann den MCP-Server op Distanz gehost gëtt.

Wéi eng Tools stellt sunra.ai 客户端库 MCP an TypingMind zur Verfügung?

sunra.ai 客户端库 stellt 10 MCP-Tools zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agente zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir sunra.ai 客户端库 MCP ze benotzen?

Nee. TypingMind ass nom Local-first-Prinzip opgebaut a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann sunra.ai 客户端库 eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir deen MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇