Logo van sunra.ai 客户端库

sunra.ai 客户端库

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

Uitgeversunra-ai
Repositorysunra-clients
TaalTypeScript
Forks
0
Sterren
7
Beschikbare tools
10
Transporttypestdio, streamable-http
Categorieën
LicentieApache-2.0
Links
  • Koppel tools aan AI-workflows

    sunra.ai 客户端库 biedt MCP-functionaliteit die compatibele AI-clients en agenten kunnen gebruiken.

  • Beschikbare tools: 10

    Bekijk hieronder de aanroepbare acties, inclusief namen en beschrijvingen als de server die beschikbaar stelt.

  • Configuratie om direct te kopiëren

    Gebruik de installatievoorbeelden om deze server in je favoriete MCP-client te configureren.

  • Belangstelling voor het opensourceproject

    Statistieken van de gekoppelde repository (sterren: 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.

Installatie

TypingMind
Vereisten:

Node.js 18+

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

Beschikbare 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

Gebruik sunra.ai 客户端库 MCP met meerdere AI-modellen

TypingMind koppelt MCP-tools aan de werkruimte. Zodra sunra.ai 客户端库 is verbonden, kun je de verbinding dus met verschillende AI-modellen in TypingMind gebruiken, zonder die voor elk model apart in te stellen. Je kunt MCP lokaal op je apparaat uitvoeren of verbinding maken met de URL van een externe MCP-server.

Optie 1: gebruik de lokale connector

Gebruik dit als de MCP-server toegang nodig heeft tot lokale bestanden, apps of privébronnen op je computer.

1

Open de MCP-instellingen

Ga in TypingMind naar Instellingen, Geavanceerde instellingen en vervolgens Model Context Protocol. Kies daar Connector instellen.

  1. Open TypingMind in je browser.
  2. Klik op het pictogram Instellingen.
  3. Ga naar Geavanceerde instellingen.
  4. Open het gedeelte Model Context Protocol.
  5. Klik op Connector instellen en kies Dit apparaat.
Instelscherm voor de TypingMind MCP-connector met Dit apparaat geselecteerd
2

Voer de connectoropdracht uit

Kies Dit apparaat, kopieer de opdracht uit TypingMind en voer deze uit in Terminal. Laat het proces draaien zolang je MCP gebruikt.

  1. Kopieer de installatieopdracht die TypingMind toont.
  2. Open Terminal op macOS of Windows Terminal op Windows.
  3. Plak de opdracht en voer deze uit.
  4. Keur de pakketinstallatie goed als Terminal vraagt of je wilt doorgaan.
  5. Laat het proces in het Terminal-venster draaien zolang je MCP-tools gebruikt.
3

Voeg sunra.ai 客户端库 toe als server

Klik op Servers bewerken zodra de connectorstatus Gereed is en plak de MCP-serverconfiguratie.

  1. Wacht tot de connectorstatus op ‘Gereed’ staat.
  2. Klik op Servers bewerken.
  3. Plak de MCP-serverconfiguratie van sunra.ai 客户端库.
  4. Sla de serverlijst op.
  5. Vernieuw de pagina als je wilt controleren of de connectorstatus nog op ‘Gereed’ staat.
MCP-instellingen van TypingMind met een actieve server en de knop Servers bewerken
{
  "mcpServers": {
    "sunra-ai-sunra-clients": {
      "command": "npx",
      "args": [
        "-y",
        "sunra-clients"
      ]
    }
  }
}
4

Gebruik de verbinding met verschillende modellen

Sla de serverlijst op, open Plug-ins en schakel de MCP-tools van sunra.ai 客户端库 in. Selecteer vervolgens een ondersteund AI-model in TypingMind en gebruik de tools in de chat of wijs ze toe aan een AI-agent.

  1. Open de pagina Plug-ins in TypingMind.
  2. Schakel de MCP-tools van sunra.ai 客户端库 in.
  3. Start een chat en kies het AI-model dat je wilt gebruiken.
  4. Gebruik de MCP-tools in een chat of wijs ze toe aan een AI-agent.
  5. Schakel wanneer nodig over naar een ander AI-model zonder opnieuw verbinding te maken met MCP.
TypingMind-chat met ingeschakelde MCP-tools en een geselecteerd AI-model
Kun je sunra.ai 客户端库 gebruiken om me hiermee te helpen?
sunra.ai 客户端库
Zeker. Ik heb het gelezen.
Dit vond ik met sunra.ai 客户端库.

Optie 2: voeg een MCP-server-URL toe

Gebruik dit als sunra.ai 客户端库 al extern wordt gehost of als je team één gedeelde connector wil waar meerdere gebruikers toegang toe hebben.

1

Open MCP-connectoren

Ga in TypingMind naar Plug-ins, open MCP-connectoren en kies URL toevoegen.

  1. Open TypingMind in je browser.
  2. Ga naar Plug-ins.
  3. Open MCP-connectoren.
  4. Klik op URL toevoegen.
TypingMind-formulier om een eigen MCP-server-URL toe te voegen
2

Plak de server-URL

Voer je server-URL in het veld Server-URL in. Voeg een verbindingsnaam, beschrijving, icoon, aangepaste HTTP-headers of OAuth-clientinstellingen toe als de server die vereist.

  1. Plak je server-URL in het veld Server-URL.
  2. Voer een verbindingsnaam in voor sunra.ai 客户端库.
  3. Voeg een beschrijving en een icoon toe als je de verbinding makkelijker wilt herkennen.
  4. Voeg aangepaste HTTP-headers of OAuth-clientgegevens toe als de server authenticatie vereist.
3

Maak de verbinding aan

Klik op Verbinding maken, ga terug naar de lijst met plug-ins en controleer of de nieuwe MCP-verbinding actief is.

  1. Klik op Verbinding maken.
  2. Ga terug naar de lijst met MCP-connectoren.
  3. Controleer of de verbinding met sunra.ai 客户端库 als actief wordt weergegeven.
  4. Vernieuw de lijst met plug-ins als de verbinding niet meteen verschijnt.
4

Wissel van model zonder opnieuw verbinding te maken

Start een chat met je favoriete model, schakel de tools van sunra.ai 客户端库 in via Plug-ins en wissel van model wanneer dat nodig is. De MCP-verbinding blijft beschikbaar in de TypingMind-werkruimte.

  1. Start een nieuwe chat in TypingMind.
  2. Selecteer het AI-model dat je wilt gebruiken.
  3. Schakel de tools van sunra.ai 客户端库 in via Plug-ins.
  4. Vraag het model om de tool te gebruiken wanneer dat nodig is.
  5. Schakel over naar een ander AI-model en gebruik dezelfde MCP-verbinding opnieuw.
TypingMind-chat met ingeschakelde MCP-tools en een geselecteerd AI-model
Kun je sunra.ai 客户端库 gebruiken om me hiermee te helpen?
sunra.ai 客户端库
Zeker. Ik heb het gelezen.
Dit vond ik met sunra.ai 客户端库.

Veelgestelde vragen

Waarvoor wordt de MCP-server sunra.ai 客户端库 gebruikt?

sunra.ai 客户端库 is een MCP-server waarmee compatibele AI-clients toegang krijgen tot externe tools en context. In TypingMind hoef je deze MCP-server maar één keer toe te voegen om de tools beschikbaar te maken in je AI-werkruimte.

Kan ik sunra.ai 客户端库 MCP met meerdere AI-modellen in TypingMind gebruiken?

Ja. TypingMind verbindt MCP-tools op werkruimteniveau. Daardoor kun je sunra.ai 客户端库 gebruiken met verschillende AI-modellen, zoals Claude, ChatGPT, Gemini of andere modellen die je in TypingMind hebt ingesteld, zonder de MCP-server voor elk model afzonderlijk in te stellen.

Waarom sunra.ai 客户端库 MCP gebruiken met TypingMind?

TypingMind is een van de beste interfaces voor chats met LLM's, omdat het meerdere AI-modellen, prompts, plug-ins, AI-agenten, API-sleutels en MCP-tools samenbrengt in één werkruimte. Als sunra.ai 客户端库 verbonden is, kun je de MCP-tools ervan gebruiken met je favoriete modellen en je chatworkflow overzichtelijk houden in TypingMind.

Hoe verbind ik sunra.ai 客户端库 MCP met TypingMind?

Je kunt sunra.ai 客户端库 met TypingMind verbinden via de lokale MCP-connector of door de URL van een externe MCP-server toe te voegen. Gebruik de lokale connector als de server toegang nodig heeft tot bestanden, apps of privébronnen op je apparaat. Gebruik een server-URL als de MCP-server extern wordt gehost.

Welke tools biedt sunra.ai 客户端库 MCP in TypingMind?

Aantal MCP-tools van sunra.ai 客户端库: 10. Je kunt elke tool inschakelen via de pagina Plug-ins in TypingMind en vervolgens gebruiken in chats of toewijzen aan AI-agenten.

Moet ik mijn API-sleutels delen met TypingMind om sunra.ai 客户端库 MCP te gebruiken?

Nee. TypingMind werkt in de eerste plaats lokaal en laat je de controle houden over je modelaanbieders, API-sleutels, prompts en MCP-configuratie. Als sunra.ai 客户端库 authenticatie vereist, voeg je bij het maken van de verbinding de vereiste headers, OAuth-instellingen of lokale configuratie voor die MCP-server toe.

Gerelateerde MCP-servers

Bekijk alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇