From d917f220423065e5a396e923bf5154c87afc5566 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Wed, 15 Oct 2025 10:44:48 -0400 Subject: [PATCH] add 10 language example pages (Go, Ruby, Java, C#, Rust, PHP, Elixir, Kotlin, Swift, Dart) and update navigation with book and all-languages links --- csharp-examples.html | 319 ++++++++++++++++++++++++++++++++++++++ dart-examples.html | 320 ++++++++++++++++++++++++++++++++++++++ elixir-examples.html | 278 +++++++++++++++++++++++++++++++++ go-examples.html | 353 ++++++++++++++++++++++++++++++++++++++++++ index.html | 2 + inference.html | 2 + java-examples.html | 348 +++++++++++++++++++++++++++++++++++++++++ kotlin-examples.html | 344 +++++++++++++++++++++++++++++++++++++++++ nodejs-examples.html | 2 + php-examples.html | 296 +++++++++++++++++++++++++++++++++++ python-examples.html | 2 + ruby-examples.html | 282 +++++++++++++++++++++++++++++++++ rust-examples.html | 360 +++++++++++++++++++++++++++++++++++++++++++ swift-examples.html | 309 +++++++++++++++++++++++++++++++++++++ uncloseai-js.html | 2 + 15 files changed, 3219 insertions(+) create mode 100644 csharp-examples.html create mode 100644 dart-examples.html create mode 100644 elixir-examples.html create mode 100644 go-examples.html create mode 100644 java-examples.html create mode 100644 kotlin-examples.html create mode 100644 php-examples.html create mode 100644 ruby-examples.html create mode 100644 rust-examples.html create mode 100644 swift-examples.html diff --git a/csharp-examples.html b/csharp-examples.html new file mode 100644 index 0000000..9ef3a65 --- /dev/null +++ b/csharp-examples.html @@ -0,0 +1,319 @@ + + + + + + + + + C# Examples | uncloseai.com + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+

uncloseai.

+

C# Examples - Free LLM & TTS AI Service

+
+ +
+ +

C# Examples

+

This page demonstrates how to use the uncloseai. API endpoints with C# using the official OpenAI .NET library. All examples use the same OpenAI-compatible API interface, making it easy to switch between different models and endpoints.

+ +

Available Endpoints:

+ + +

C# Client Installation

+

Install the OpenAI NuGet package using the .NET CLI:

+
dotnet add package OpenAI
+ +

Or via Package Manager Console:

+
Install-Package OpenAI
+ +

Non-Streaming Examples

+

Non-streaming mode waits for the complete response before returning. This is simpler to use but provides no intermediate feedback during generation.

+ +

Using Hermes (General Purpose)

+
using OpenAI.Chat;
+
+var client = new ChatClient(
+    model: "adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic",
+    apiKey: "choose-any-value",
+    new OpenAIClientOptions
+    {
+        Endpoint = new Uri("https://hermes.ai.unturf.com/v1")
+    }
+);
+
+ChatCompletion completion = await client.CompleteChatAsync(
+    new List<ChatMessage>
+    {
+        new UserChatMessage("Give a Python Fizzbuzz solution in one line of code?")
+    },
+    new ChatCompletionOptions
+    {
+        Temperature = 0.5f,
+        MaxTokens = 150
+    }
+);
+
+Console.WriteLine(completion.Content[0].Text);
+
+ +

Using Qwen 3 Coder (Specialized for Coding)

+
using OpenAI.Chat;
+
+var client = new ChatClient(
+    model: "hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M",
+    apiKey: "choose-any-value",
+    new OpenAIClientOptions
+    {
+        Endpoint = new Uri("https://qwen.ai.unturf.com/v1")
+    }
+);
+
+ChatCompletion completion = await client.CompleteChatAsync(
+    new List<ChatMessage>
+    {
+        new UserChatMessage("Give a Python Fizzbuzz solution in one line of code?")
+    },
+    new ChatCompletionOptions
+    {
+        Temperature = 0.5f,
+        MaxTokens = 150
+    }
+);
+
+Console.WriteLine(completion.Content[0].Text);
+
+ +

Streaming Examples

+

Streaming mode returns chunks of the response as they are generated, providing real-time feedback. This is ideal for interactive applications and long responses.

+ +

Using Hermes (General Purpose)

+
using OpenAI.Chat;
+
+var client = new ChatClient(
+    model: "adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic",
+    apiKey: "choose-any-value",
+    new OpenAIClientOptions
+    {
+        Endpoint = new Uri("https://hermes.ai.unturf.com/v1")
+    }
+);
+
+var streamingUpdates = client.CompleteChatStreamingAsync(
+    new List<ChatMessage>
+    {
+        new UserChatMessage("Give a Python Fizzbuzz solution in one line of code?")
+    },
+    new ChatCompletionOptions
+    {
+        Temperature = 0.5f,
+        MaxTokens = 150
+    }
+);
+
+await foreach (var update in streamingUpdates)
+{
+    foreach (var contentPart in update.ContentUpdate)
+    {
+        Console.Write(contentPart.Text);
+    }
+}
+
+ +

Using Qwen 3 Coder (Specialized for Coding)

+
using OpenAI.Chat;
+
+var client = new ChatClient(
+    model: "hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M",
+    apiKey: "choose-any-value",
+    new OpenAIClientOptions
+    {
+        Endpoint = new Uri("https://qwen.ai.unturf.com/v1")
+    }
+);
+
+var streamingUpdates = client.CompleteChatStreamingAsync(
+    new List<ChatMessage>
+    {
+        new UserChatMessage("Give a Python Fizzbuzz solution in one line of code?")
+    },
+    new ChatCompletionOptions
+    {
+        Temperature = 0.5f,
+        MaxTokens = 150
+    }
+);
+
+await foreach (var update in streamingUpdates)
+{
+    foreach (var contentPart in update.ContentUpdate)
+    {
+        Console.Write(contentPart.Text);
+    }
+}
+
+ +

Text-to-Speech Example

+

Generate audio speech from text using the TTS endpoint. The audio is saved as an MP3 file.

+ +
using OpenAI.Audio;
+
+var client = new AudioClient(
+    model: "tts-1",
+    apiKey: "YOLO",
+    new OpenAIClientOptions
+    {
+        Endpoint = new Uri("https://speech.ai.unturf.com/v1")
+    }
+);
+
+BinaryData speech = await client.GenerateSpeechAsync(
+    "I think so therefore, Today is a wonderful day to build something people love!",
+    GeneratedSpeechVoice.Alloy,
+    new SpeechGenerationOptions
+    {
+        Speed = 0.9f
+    }
+);
+
+await File.WriteAllBytesAsync("speech.mp3", speech.ToArray());
+
+ + + + + + +
+ + + + + + diff --git a/dart-examples.html b/dart-examples.html new file mode 100644 index 0000000..aee202e --- /dev/null +++ b/dart-examples.html @@ -0,0 +1,320 @@ + + + + + + + + + Dart Examples | uncloseai.com + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+

uncloseai.

+

Dart Examples - Free LLM & TTS AI Service

+
+ +
+ +

Dart Examples

+

This page demonstrates how to use the uncloseai. API endpoints with Dart/Flutter using the dart_openai community library. All examples use the same OpenAI-compatible API interface, making it easy to switch between different models and endpoints.

+ +

Available Endpoints:

+ + +

Dart Client Installation

+

Add dart_openai to your pubspec.yaml:

+
dependencies:
+  dart_openai: ^5.1.0
+ +

Non-Streaming Examples

+

Non-streaming mode waits for the complete response before returning. This is simpler to use but provides no intermediate feedback during generation.

+ +

Using Hermes (General Purpose)

+
import 'package:dart_openai/dart_openai.dart';
+
+void main() async {
+  OpenAI.apiKey = "choose-any-value";
+  OpenAI.baseUrl = "https://hermes.ai.unturf.com/v1";
+
+  final chatCompletion = await OpenAI.instance.chat.create(
+    model: "adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic",
+    messages: [
+      OpenAIChatCompletionChoiceMessageModel(
+        role: OpenAIChatMessageRole.user,
+        content: [
+          OpenAIChatCompletionChoiceMessageContentItemModel.text(
+            "Give a Python Fizzbuzz solution in one line of code?"
+          ),
+        ],
+      ),
+    ],
+    temperature: 0.5,
+    maxTokens: 150,
+  );
+
+  print(chatCompletion.choices.first.message.content?.first.text);
+}
+
+ +

Using Qwen 3 Coder (Specialized for Coding)

+
import 'package:dart_openai/dart_openai.dart';
+
+void main() async {
+  OpenAI.apiKey = "choose-any-value";
+  OpenAI.baseUrl = "https://qwen.ai.unturf.com/v1";
+
+  final chatCompletion = await OpenAI.instance.chat.create(
+    model: "hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M",
+    messages: [
+      OpenAIChatCompletionChoiceMessageModel(
+        role: OpenAIChatMessageRole.user,
+        content: [
+          OpenAIChatCompletionChoiceMessageContentItemModel.text(
+            "Give a Python Fizzbuzz solution in one line of code?"
+          ),
+        ],
+      ),
+    ],
+    temperature: 0.5,
+    maxTokens: 150,
+  );
+
+  print(chatCompletion.choices.first.message.content?.first.text);
+}
+
+ +

Streaming Examples

+

Streaming mode returns chunks of the response as they are generated, providing real-time feedback. This is ideal for interactive applications and long responses.

+ +

Using Hermes (General Purpose)

+
import 'package:dart_openai/dart_openai.dart';
+import 'dart:io';
+
+void main() async {
+  OpenAI.apiKey = "choose-any-value";
+  OpenAI.baseUrl = "https://hermes.ai.unturf.com/v1";
+
+  final chatStream = OpenAI.instance.chat.createStream(
+    model: "adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic",
+    messages: [
+      OpenAIChatCompletionChoiceMessageModel(
+        role: OpenAIChatMessageRole.user,
+        content: [
+          OpenAIChatCompletionChoiceMessageContentItemModel.text(
+            "Give a Python Fizzbuzz solution in one line of code?"
+          ),
+        ],
+      ),
+    ],
+    temperature: 0.5,
+    maxTokens: 150,
+  );
+
+  await for (final chunk in chatStream) {
+    final content = chunk.choices.first.delta.content;
+    if (content != null && content.isNotEmpty) {
+      stdout.write(content.first.text);
+    }
+  }
+}
+
+ +

Using Qwen 3 Coder (Specialized for Coding)

+
import 'package:dart_openai/dart_openai.dart';
+import 'dart:io';
+
+void main() async {
+  OpenAI.apiKey = "choose-any-value";
+  OpenAI.baseUrl = "https://qwen.ai.unturf.com/v1";
+
+  final chatStream = OpenAI.instance.chat.createStream(
+    model: "hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M",
+    messages: [
+      OpenAIChatCompletionChoiceMessageModel(
+        role: OpenAIChatMessageRole.user,
+        content: [
+          OpenAIChatCompletionChoiceMessageContentItemModel.text(
+            "Give a Python Fizzbuzz solution in one line of code?"
+          ),
+        ],
+      ),
+    ],
+    temperature: 0.5,
+    maxTokens: 150,
+  );
+
+  await for (final chunk in chatStream) {
+    final content = chunk.choices.first.delta.content;
+    if (content != null && content.isNotEmpty) {
+      stdout.write(content.first.text);
+    }
+  }
+}
+
+ +

Text-to-Speech Example

+

Generate audio speech from text using the TTS endpoint. The audio is saved as an MP3 file.

+ +
import 'package:dart_openai/dart_openai.dart';
+import 'dart:io';
+
+void main() async {
+  OpenAI.apiKey = "YOLO";
+  OpenAI.baseUrl = "https://speech.ai.unturf.com/v1";
+
+  final speech = await OpenAI.instance.audio.createSpeech(
+    model: "tts-1",
+    input: "I think so therefore, Today is a wonderful day to build something people love!",
+    voice: "alloy",
+    speed: 0.9,
+  );
+
+  final file = File("speech.mp3");
+  await file.writeAsBytes(speech);
+  print("Audio saved to: ${file.path}");
+}
+
+ + + + + + +
+ + + + + + diff --git a/elixir-examples.html b/elixir-examples.html new file mode 100644 index 0000000..565f3aa --- /dev/null +++ b/elixir-examples.html @@ -0,0 +1,278 @@ + + + + + + + + + Elixir Examples | uncloseai.com + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+

uncloseai.

+

Elixir Examples - Free LLM & TTS AI Service

+
+ +
+ +

Elixir Examples

+

This page demonstrates how to use the uncloseai. API endpoints with Elixir using the openai_ex community library. All examples use the same OpenAI-compatible API interface, making it easy to switch between different models and endpoints.

+ +

Available Endpoints:

+ + +

Elixir Client Installation

+

Add openai_ex to your mix.exs dependencies:

+
def deps do
+  [
+    {:openai_ex, "~> 0.9.17"}
+  ]
+end
+ +

Non-Streaming Examples

+

Non-streaming mode waits for the complete response before returning. This is simpler to use but provides no intermediate feedback during generation.

+ +

Using Hermes (General Purpose)

+
config = %OpenaiEx.Config{
+  api_key: "choose-any-value",
+  api_url: "https://hermes.ai.unturf.com/v1"
+}
+
+{:ok, response} = OpenaiEx.ChatCompletion.create(
+  config,
+  model: "adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic",
+  messages: [
+    %{role: "user", content: "Give a Python Fizzbuzz solution in one line of code?"}
+  ],
+  temperature: 0.5,
+  max_tokens: 150
+)
+
+IO.puts(response["choices"] |> List.first() |> get_in(["message", "content"]))
+
+ +

Using Qwen 3 Coder (Specialized for Coding)

+
config = %OpenaiEx.Config{
+  api_key: "choose-any-value",
+  api_url: "https://qwen.ai.unturf.com/v1"
+}
+
+{:ok, response} = OpenaiEx.ChatCompletion.create(
+  config,
+  model: "hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M",
+  messages: [
+    %{role: "user", content: "Give a Python Fizzbuzz solution in one line of code?"}
+  ],
+  temperature: 0.5,
+  max_tokens: 150
+)
+
+IO.puts(response["choices"] |> List.first() |> get_in(["message", "content"]))
+
+ +

Streaming Examples

+

Streaming mode returns chunks of the response as they are generated, providing real-time feedback. This is ideal for interactive applications and long responses.

+ +

Using Hermes (General Purpose)

+
config = %OpenaiEx.Config{
+  api_key: "choose-any-value",
+  api_url: "https://hermes.ai.unturf.com/v1"
+}
+
+OpenaiEx.ChatCompletion.create_stream(
+  config,
+  model: "adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic",
+  messages: [
+    %{role: "user", content: "Give a Python Fizzbuzz solution in one line of code?"}
+  ],
+  temperature: 0.5,
+  max_tokens: 150
+)
+|> Stream.each(fn chunk ->
+  content = get_in(chunk, ["choices", Access.at(0), "delta", "content"])
+  if content, do: IO.write(content)
+end)
+|> Stream.run()
+
+ +

Using Qwen 3 Coder (Specialized for Coding)

+
config = %OpenaiEx.Config{
+  api_key: "choose-any-value",
+  api_url: "https://qwen.ai.unturf.com/v1"
+}
+
+OpenaiEx.ChatCompletion.create_stream(
+  config,
+  model: "hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M",
+  messages: [
+    %{role: "user", content: "Give a Python Fizzbuzz solution in one line of code?"}
+  ],
+  temperature: 0.5,
+  max_tokens: 150
+)
+|> Stream.each(fn chunk ->
+  content = get_in(chunk, ["choices", Access.at(0), "delta", "content"])
+  if content, do: IO.write(content)
+end)
+|> Stream.run()
+
+ +

Text-to-Speech Example

+

Generate audio speech from text using the TTS endpoint. The audio is saved as an MP3 file.

+ +
config = %OpenaiEx.Config{
+  api_key: "YOLO",
+  api_url: "https://speech.ai.unturf.com/v1"
+}
+
+{:ok, audio_data} = OpenaiEx.Audio.Speech.create(
+  config,
+  model: "tts-1",
+  voice: "alloy",
+  input: "I think so therefore, Today is a wonderful day to build something people love!",
+  speed: 0.9
+)
+
+File.write!("speech.mp3", audio_data)
+
+ + + + + + +
+ + + + + + diff --git a/go-examples.html b/go-examples.html new file mode 100644 index 0000000..3a920ed --- /dev/null +++ b/go-examples.html @@ -0,0 +1,353 @@ + + + + + + + + + Go Examples | uncloseai.com + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+

uncloseai.

+

Go Examples - Free LLM & TTS AI Service

+
+ +
+ +

Go Examples

+

This page demonstrates how to use the uncloseai. API endpoints with Go using the official OpenAI Go client library. All examples use the same OpenAI-compatible API interface, making it easy to switch between different models and endpoints.

+ +

Available Endpoints:

+ + +

Go Client Installation

+

To install the official OpenAI Go package, use go get:

+
go get github.com/openai/openai-go
+ +

Non-Streaming Examples

+

Non-streaming mode waits for the complete response before returning. This is simpler to use but provides no intermediate feedback during generation.

+ +

Using Hermes (General Purpose)

+
package main
+
+import (
+    "context"
+    "fmt"
+    "github.com/openai/openai-go"
+    "github.com/openai/openai-go/option"
+)
+
+func main() {
+    client := openai.NewClient(
+        option.WithBaseURL("https://hermes.ai.unturf.com/v1"),
+        option.WithAPIKey("choose-any-value"),
+    )
+
+    response, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
+        Model: openai.F("adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic"),
+        Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
+            openai.UserMessage("Give a Python Fizzbuzz solution in one line of code?"),
+        }),
+        Temperature: openai.Float(0.5),
+        MaxTokens:   openai.Int(150),
+    })
+
+    if err != nil {
+        panic(err)
+    }
+
+    fmt.Println(response.Choices[0].Message.Content)
+}
+
+ +

Using Qwen 3 Coder (Specialized for Coding)

+
package main
+
+import (
+    "context"
+    "fmt"
+    "github.com/openai/openai-go"
+    "github.com/openai/openai-go/option"
+)
+
+func main() {
+    client := openai.NewClient(
+        option.WithBaseURL("https://qwen.ai.unturf.com/v1"),
+        option.WithAPIKey("choose-any-value"),
+    )
+
+    response, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
+        Model: openai.F("hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M"),
+        Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
+            openai.UserMessage("Give a Python Fizzbuzz solution in one line of code?"),
+        }),
+        Temperature: openai.Float(0.5),
+        MaxTokens:   openai.Int(150),
+    })
+
+    if err != nil {
+        panic(err)
+    }
+
+    fmt.Println(response.Choices[0].Message.Content)
+}
+
+ +

Streaming Examples

+

Streaming mode returns chunks of the response as they are generated, providing real-time feedback. This is ideal for interactive applications and long responses.

+ +

Using Hermes (General Purpose)

+
package main
+
+import (
+    "context"
+    "fmt"
+    "github.com/openai/openai-go"
+    "github.com/openai/openai-go/option"
+)
+
+func main() {
+    client := openai.NewClient(
+        option.WithBaseURL("https://hermes.ai.unturf.com/v1"),
+        option.WithAPIKey("choose-any-value"),
+    )
+
+    stream := client.Chat.Completions.NewStreaming(context.Background(), openai.ChatCompletionNewParams{
+        Model: openai.F("adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic"),
+        Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
+            openai.UserMessage("Give a Python Fizzbuzz solution in one line of code?"),
+        }),
+        Temperature: openai.Float(0.5),
+        MaxTokens:   openai.Int(150),
+    })
+
+    for stream.Next() {
+        chunk := stream.Current()
+        if len(chunk.Choices) > 0 && chunk.Choices[0].Delta.Content != "" {
+            fmt.Print(chunk.Choices[0].Delta.Content)
+        }
+    }
+
+    if err := stream.Err(); err != nil {
+        panic(err)
+    }
+}
+
+ +

Using Qwen 3 Coder (Specialized for Coding)

+
package main
+
+import (
+    "context"
+    "fmt"
+    "github.com/openai/openai-go"
+    "github.com/openai/openai-go/option"
+)
+
+func main() {
+    client := openai.NewClient(
+        option.WithBaseURL("https://qwen.ai.unturf.com/v1"),
+        option.WithAPIKey("choose-any-value"),
+    )
+
+    stream := client.Chat.Completions.NewStreaming(context.Background(), openai.ChatCompletionNewParams{
+        Model: openai.F("hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M"),
+        Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
+            openai.UserMessage("Give a Python Fizzbuzz solution in one line of code?"),
+        }),
+        Temperature: openai.Float(0.5),
+        MaxTokens:   openai.Int(150),
+    })
+
+    for stream.Next() {
+        chunk := stream.Current()
+        if len(chunk.Choices) > 0 && chunk.Choices[0].Delta.Content != "" {
+            fmt.Print(chunk.Choices[0].Delta.Content)
+        }
+    }
+
+    if err := stream.Err(); err != nil {
+        panic(err)
+    }
+}
+
+ +

Text-to-Speech Example

+

Generate audio speech from text using the TTS endpoint. The audio is saved as an MP3 file.

+ +
package main
+
+import (
+    "context"
+    "io"
+    "os"
+    "github.com/openai/openai-go"
+    "github.com/openai/openai-go/option"
+)
+
+func main() {
+    client := openai.NewClient(
+        option.WithBaseURL("https://speech.ai.unturf.com/v1"),
+        option.WithAPIKey("YOLO"),
+    )
+
+    response, err := client.Audio.Speech.New(context.Background(), openai.AudioSpeechNewParams{
+        Model: openai.F(openai.SpeechModelTTS1),
+        Voice: openai.F(openai.AudioSpeechNewParamsVoiceAlloy),
+        Input: openai.F("I think so therefore, Today is a wonderful day to build something people love!"),
+        Speed: openai.Float(0.9),
+    })
+
+    if err != nil {
+        panic(err)
+    }
+    defer response.Body.Close()
+
+    file, err := os.Create("speech.mp3")
+    if err != nil {
+        panic(err)
+    }
+    defer file.Close()
+
+    _, err = io.Copy(file, response.Body)
+    if err != nil {
+        panic(err)
+    }
+}
+
+ + + + + + +
+ + + + + + diff --git a/index.html b/index.html index 371981e..7d0055a 100644 --- a/index.html +++ b/index.html @@ -62,6 +62,8 @@
  • Node.js Examples
  • uncloseai.js Docs
  • Inference Setup
  • +
  • 🔗 All Languages
  • +
  • 📚 Book
  • diff --git a/inference.html b/inference.html index a32669c..f8427d9 100644 --- a/inference.html +++ b/inference.html @@ -53,6 +53,8 @@
  • Node.js Examples
  • uncloseai.js Docs
  • Inference Setup
  • +
  • 🔗 All Languages
  • +
  • 📚 Book
  • diff --git a/java-examples.html b/java-examples.html new file mode 100644 index 0000000..6ca108d --- /dev/null +++ b/java-examples.html @@ -0,0 +1,348 @@ + + + + + + + + + Java Examples | uncloseai.com + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +

    uncloseai.

    +

    Java Examples - Free LLM & TTS AI Service

    +
    + +
    + +

    Java Examples

    +

    This page demonstrates how to use the uncloseai. API endpoints with Java using the official OpenAI Java library. All examples use the same OpenAI-compatible API interface, making it easy to switch between different models and endpoints.

    + +

    Available Endpoints:

    + + +

    Java Client Installation

    +

    Add the official OpenAI Java library to your Maven pom.xml:

    +
    <dependency>
    +    <groupId>com.openai</groupId>
    +    <artifactId>openai-java</artifactId>
    +    <version>0.8.1</version>
    +</dependency>
    + +

    Or for Gradle:

    +
    implementation 'com.openai:openai-java:0.8.1'
    + +

    Non-Streaming Examples

    +

    Non-streaming mode waits for the complete response before returning. This is simpler to use but provides no intermediate feedback during generation.

    + +

    Using Hermes (General Purpose)

    +
    import com.openai.client.OpenAIClient;
    +import com.openai.client.okhttp.OpenAIOkHttpClient;
    +import com.openai.models.*;
    +import java.util.List;
    +
    +public class HermesExample {
    +    public static void main(String[] args) {
    +        OpenAIClient client = OpenAIOkHttpClient.builder()
    +            .apiKey("choose-any-value")
    +            .baseURL("https://hermes.ai.unturf.com/v1")
    +            .build();
    +
    +        ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
    +            .model("adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic")
    +            .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam(
    +                ChatCompletionUserMessageParam.builder()
    +                    .role(ChatCompletionUserMessageParam.Role.USER)
    +                    .content(ChatCompletionUserMessageParam.Content.ofTextContent(
    +                        "Give a Python Fizzbuzz solution in one line of code?"
    +                    ))
    +                    .build()
    +            ))
    +            .temperature(0.5)
    +            .maxTokens(150L)
    +            .build();
    +
    +        ChatCompletion completion = client.chat().completions().create(params);
    +        System.out.println(completion.choices().get(0).message().content().get());
    +    }
    +}
    +
    + +

    Using Qwen 3 Coder (Specialized for Coding)

    +
    import com.openai.client.OpenAIClient;
    +import com.openai.client.okhttp.OpenAIOkHttpClient;
    +import com.openai.models.*;
    +import java.util.List;
    +
    +public class QwenExample {
    +    public static void main(String[] args) {
    +        OpenAIClient client = OpenAIOkHttpClient.builder()
    +            .apiKey("choose-any-value")
    +            .baseURL("https://qwen.ai.unturf.com/v1")
    +            .build();
    +
    +        ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
    +            .model("hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M")
    +            .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam(
    +                ChatCompletionUserMessageParam.builder()
    +                    .role(ChatCompletionUserMessageParam.Role.USER)
    +                    .content(ChatCompletionUserMessageParam.Content.ofTextContent(
    +                        "Give a Python Fizzbuzz solution in one line of code?"
    +                    ))
    +                    .build()
    +            ))
    +            .temperature(0.5)
    +            .maxTokens(150L)
    +            .build();
    +
    +        ChatCompletion completion = client.chat().completions().create(params);
    +        System.out.println(completion.choices().get(0).message().content().get());
    +    }
    +}
    +
    + +

    Streaming Examples

    +

    Streaming mode returns chunks of the response as they are generated, providing real-time feedback. This is ideal for interactive applications and long responses.

    + +

    Using Hermes (General Purpose)

    +
    import com.openai.client.OpenAIClient;
    +import com.openai.client.okhttp.OpenAIOkHttpClient;
    +import com.openai.models.*;
    +
    +public class HermesStreamExample {
    +    public static void main(String[] args) {
    +        OpenAIClient client = OpenAIOkHttpClient.builder()
    +            .apiKey("choose-any-value")
    +            .baseURL("https://hermes.ai.unturf.com/v1")
    +            .build();
    +
    +        ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
    +            .model("adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic")
    +            .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam(
    +                ChatCompletionUserMessageParam.builder()
    +                    .role(ChatCompletionUserMessageParam.Role.USER)
    +                    .content(ChatCompletionUserMessageParam.Content.ofTextContent(
    +                        "Give a Python Fizzbuzz solution in one line of code?"
    +                    ))
    +                    .build()
    +            ))
    +            .temperature(0.5)
    +            .maxTokens(150L)
    +            .build();
    +
    +        client.chat().completions().createStreaming(params)
    +            .forEach(chunk -> {
    +                String content = chunk.choices().get(0).delta().content().orElse("");
    +                if (!content.isEmpty()) {
    +                    System.out.print(content);
    +                }
    +            });
    +    }
    +}
    +
    + +

    Using Qwen 3 Coder (Specialized for Coding)

    +
    import com.openai.client.OpenAIClient;
    +import com.openai.client.okhttp.OpenAIOkHttpClient;
    +import com.openai.models.*;
    +
    +public class QwenStreamExample {
    +    public static void main(String[] args) {
    +        OpenAIClient client = OpenAIOkHttpClient.builder()
    +            .apiKey("choose-any-value")
    +            .baseURL("https://qwen.ai.unturf.com/v1")
    +            .build();
    +
    +        ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
    +            .model("hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M")
    +            .addMessage(ChatCompletionMessageParam.ofChatCompletionUserMessageParam(
    +                ChatCompletionUserMessageParam.builder()
    +                    .role(ChatCompletionUserMessageParam.Role.USER)
    +                    .content(ChatCompletionUserMessageParam.Content.ofTextContent(
    +                        "Give a Python Fizzbuzz solution in one line of code?"
    +                    ))
    +                    .build()
    +            ))
    +            .temperature(0.5)
    +            .maxTokens(150L)
    +            .build();
    +
    +        client.chat().completions().createStreaming(params)
    +            .forEach(chunk -> {
    +                String content = chunk.choices().get(0).delta().content().orElse("");
    +                if (!content.isEmpty()) {
    +                    System.out.print(content);
    +                }
    +            });
    +    }
    +}
    +
    + +

    Text-to-Speech Example

    +

    Generate audio speech from text using the TTS endpoint. The audio is saved as an MP3 file.

    + +
    import com.openai.client.OpenAIClient;
    +import com.openai.client.okhttp.OpenAIOkHttpClient;
    +import com.openai.models.*;
    +import java.io.FileOutputStream;
    +import java.io.IOException;
    +
    +public class TTSExample {
    +    public static void main(String[] args) throws IOException {
    +        OpenAIClient client = OpenAIOkHttpClient.builder()
    +            .apiKey("YOLO")
    +            .baseURL("https://speech.ai.unturf.com/v1")
    +            .build();
    +
    +        SpeechCreateParams params = SpeechCreateParams.builder()
    +            .model(SpeechModel.TTS_1)
    +            .voice(SpeechCreateParams.Voice.ALLOY)
    +            .input("I think so therefore, Today is a wonderful day to build something people love!")
    +            .speed(0.9)
    +            .build();
    +
    +        byte[] audioBytes = client.audio().speech().create(params);
    +
    +        try (FileOutputStream fos = new FileOutputStream("speech.mp3")) {
    +            fos.write(audioBytes);
    +        }
    +    }
    +}
    +
    + + + + + + +
    + + + + + + diff --git a/kotlin-examples.html b/kotlin-examples.html new file mode 100644 index 0000000..a643b20 --- /dev/null +++ b/kotlin-examples.html @@ -0,0 +1,344 @@ + + + + + + + + + Kotlin Examples | uncloseai.com + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +

    uncloseai.

    +

    Kotlin Examples - Free LLM & TTS AI Service

    +
    + +
    + +

    Kotlin Examples

    +

    This page demonstrates how to use the uncloseai. API endpoints with Kotlin using the openai-kotlin community library. All examples use the same OpenAI-compatible API interface, making it easy to switch between different models and endpoints.

    + +

    Available Endpoints:

    + + +

    Kotlin Client Installation

    +

    Add openai-kotlin to your build.gradle.kts:

    +
    dependencies {
    +    implementation("com.aallam.openai:openai-client:3.8.2")
    +    implementation("io.ktor:ktor-client-okhttp:2.3.12")
    +}
    + +

    Non-Streaming Examples

    +

    Non-streaming mode waits for the complete response before returning. This is simpler to use but provides no intermediate feedback during generation.

    + +

    Using Hermes (General Purpose)

    +
    import com.aallam.openai.api.chat.*
    +import com.aallam.openai.api.model.ModelId
    +import com.aallam.openai.client.OpenAI
    +import com.aallam.openai.client.OpenAIConfig
    +import com.aallam.openai.client.OpenAIHost
    +
    +suspend fun main() {
    +    val openAI = OpenAI(
    +        OpenAIConfig(
    +            token = "choose-any-value",
    +            host = OpenAIHost("https://hermes.ai.unturf.com/v1")
    +        )
    +    )
    +
    +    val chatCompletionRequest = ChatCompletionRequest(
    +        model = ModelId("adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic"),
    +        messages = listOf(
    +            ChatMessage(
    +                role = ChatRole.User,
    +                content = "Give a Python Fizzbuzz solution in one line of code?"
    +            )
    +        ),
    +        temperature = 0.5,
    +        maxTokens = 150
    +    )
    +
    +    val completion = openAI.chatCompletion(chatCompletionRequest)
    +    println(completion.choices[0].message.content)
    +}
    +
    + +

    Using Qwen 3 Coder (Specialized for Coding)

    +
    import com.aallam.openai.api.chat.*
    +import com.aallam.openai.api.model.ModelId
    +import com.aallam.openai.client.OpenAI
    +import com.aallam.openai.client.OpenAIConfig
    +import com.aallam.openai.client.OpenAIHost
    +
    +suspend fun main() {
    +    val openAI = OpenAI(
    +        OpenAIConfig(
    +            token = "choose-any-value",
    +            host = OpenAIHost("https://qwen.ai.unturf.com/v1")
    +        )
    +    )
    +
    +    val chatCompletionRequest = ChatCompletionRequest(
    +        model = ModelId("hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M"),
    +        messages = listOf(
    +            ChatMessage(
    +                role = ChatRole.User,
    +                content = "Give a Python Fizzbuzz solution in one line of code?"
    +            )
    +        ),
    +        temperature = 0.5,
    +        maxTokens = 150
    +    )
    +
    +    val completion = openAI.chatCompletion(chatCompletionRequest)
    +    println(completion.choices[0].message.content)
    +}
    +
    + +

    Streaming Examples

    +

    Streaming mode returns chunks of the response as they are generated, providing real-time feedback. This is ideal for interactive applications and long responses.

    + +

    Using Hermes (General Purpose)

    +
    import com.aallam.openai.api.chat.*
    +import com.aallam.openai.api.model.ModelId
    +import com.aallam.openai.client.OpenAI
    +import com.aallam.openai.client.OpenAIConfig
    +import com.aallam.openai.client.OpenAIHost
    +import kotlinx.coroutines.flow.collect
    +
    +suspend fun main() {
    +    val openAI = OpenAI(
    +        OpenAIConfig(
    +            token = "choose-any-value",
    +            host = OpenAIHost("https://hermes.ai.unturf.com/v1")
    +        )
    +    )
    +
    +    val chatCompletionRequest = ChatCompletionRequest(
    +        model = ModelId("adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic"),
    +        messages = listOf(
    +            ChatMessage(
    +                role = ChatRole.User,
    +                content = "Give a Python Fizzbuzz solution in one line of code?"
    +            )
    +        ),
    +        temperature = 0.5,
    +        maxTokens = 150
    +    )
    +
    +    openAI.chatCompletions(chatCompletionRequest).collect { chunk ->
    +        chunk.choices.forEach { choice ->
    +            choice.delta.content?.let { print(it) }
    +        }
    +    }
    +}
    +
    + +

    Using Qwen 3 Coder (Specialized for Coding)

    +
    import com.aallam.openai.api.chat.*
    +import com.aallam.openai.api.model.ModelId
    +import com.aallam.openai.client.OpenAI
    +import com.aallam.openai.client.OpenAIConfig
    +import com.aallam.openai.client.OpenAIHost
    +import kotlinx.coroutines.flow.collect
    +
    +suspend fun main() {
    +    val openAI = OpenAI(
    +        OpenAIConfig(
    +            token = "choose-any-value",
    +            host = OpenAIHost("https://qwen.ai.unturf.com/v1")
    +        )
    +    )
    +
    +    val chatCompletionRequest = ChatCompletionRequest(
    +        model = ModelId("hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M"),
    +        messages = listOf(
    +            ChatMessage(
    +                role = ChatRole.User,
    +                content = "Give a Python Fizzbuzz solution in one line of code?"
    +            )
    +        ),
    +        temperature = 0.5,
    +        maxTokens = 150
    +    )
    +
    +    openAI.chatCompletions(chatCompletionRequest).collect { chunk ->
    +        chunk.choices.forEach { choice ->
    +            choice.delta.content?.let { print(it) }
    +        }
    +    }
    +}
    +
    + +

    Text-to-Speech Example

    +

    Generate audio speech from text using the TTS endpoint. The audio is saved as an MP3 file.

    + +
    import com.aallam.openai.api.audio.SpeechRequest
    +import com.aallam.openai.api.audio.Voice
    +import com.aallam.openai.api.model.ModelId
    +import com.aallam.openai.client.OpenAI
    +import com.aallam.openai.client.OpenAIConfig
    +import com.aallam.openai.client.OpenAIHost
    +import java.io.File
    +
    +suspend fun main() {
    +    val openAI = OpenAI(
    +        OpenAIConfig(
    +            token = "YOLO",
    +            host = OpenAIHost("https://speech.ai.unturf.com/v1")
    +        )
    +    )
    +
    +    val speechRequest = SpeechRequest(
    +        model = ModelId("tts-1"),
    +        input = "I think so therefore, Today is a wonderful day to build something people love!",
    +        voice = Voice.Alloy,
    +        speed = 0.9
    +    )
    +
    +    val speech = openAI.speech(speechRequest)
    +    File("speech.mp3").writeBytes(speech)
    +}
    +
    + + + + + + +
    + + + + + + diff --git a/nodejs-examples.html b/nodejs-examples.html index 892aaf5..6bc5e57 100644 --- a/nodejs-examples.html +++ b/nodejs-examples.html @@ -53,6 +53,8 @@
  • Node.js Examples
  • uncloseai.js Docs
  • Inference Setup
  • +
  • 🔗 All Languages
  • +
  • 📚 Book
  • diff --git a/php-examples.html b/php-examples.html new file mode 100644 index 0000000..eadcc47 --- /dev/null +++ b/php-examples.html @@ -0,0 +1,296 @@ + + + + + + + + + PHP Examples | uncloseai.com + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +

    uncloseai.

    +

    PHP Examples - Free LLM & TTS AI Service

    +
    + +
    + +

    PHP Examples

    +

    This page demonstrates how to use the uncloseai. API endpoints with PHP using the openai-php/client community library. All examples use the same OpenAI-compatible API interface, making it easy to switch between different models and endpoints.

    + +

    Available Endpoints:

    + + +

    PHP Client Installation

    +

    Install the OpenAI PHP client via Composer:

    +
    composer require openai-php/client
    + +

    Non-Streaming Examples

    +

    Non-streaming mode waits for the complete response before returning. This is simpler to use but provides no intermediate feedback during generation.

    + +

    Using Hermes (General Purpose)

    +
    <?php
    +
    +require 'vendor/autoload.php';
    +
    +use OpenAI;
    +
    +$client = OpenAI::factory()
    +    ->withApiKey('choose-any-value')
    +    ->withBaseUri('https://hermes.ai.unturf.com/v1')
    +    ->make();
    +
    +$response = $client->chat()->create([
    +    'model' => 'adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic',
    +    'messages' => [
    +        ['role' => 'user', 'content' => 'Give a Python Fizzbuzz solution in one line of code?'],
    +    ],
    +    'temperature' => 0.5,
    +    'max_tokens' => 150,
    +]);
    +
    +echo $response->choices[0]->message->content;
    +
    + +

    Using Qwen 3 Coder (Specialized for Coding)

    +
    <?php
    +
    +require 'vendor/autoload.php';
    +
    +use OpenAI;
    +
    +$client = OpenAI::factory()
    +    ->withApiKey('choose-any-value')
    +    ->withBaseUri('https://qwen.ai.unturf.com/v1')
    +    ->make();
    +
    +$response = $client->chat()->create([
    +    'model' => 'hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M',
    +    'messages' => [
    +        ['role' => 'user', 'content' => 'Give a Python Fizzbuzz solution in one line of code?'],
    +    ],
    +    'temperature' => 0.5,
    +    'max_tokens' => 150,
    +]);
    +
    +echo $response->choices[0]->message->content;
    +
    + +

    Streaming Examples

    +

    Streaming mode returns chunks of the response as they are generated, providing real-time feedback. This is ideal for interactive applications and long responses.

    + +

    Using Hermes (General Purpose)

    +
    <?php
    +
    +require 'vendor/autoload.php';
    +
    +use OpenAI;
    +
    +$client = OpenAI::factory()
    +    ->withApiKey('choose-any-value')
    +    ->withBaseUri('https://hermes.ai.unturf.com/v1')
    +    ->make();
    +
    +$stream = $client->chat()->createStreamed([
    +    'model' => 'adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic',
    +    'messages' => [
    +        ['role' => 'user', 'content' => 'Give a Python Fizzbuzz solution in one line of code?'],
    +    ],
    +    'temperature' => 0.5,
    +    'max_tokens' => 150,
    +]);
    +
    +foreach ($stream as $response) {
    +    echo $response->choices[0]->delta->content ?? '';
    +}
    +
    + +

    Using Qwen 3 Coder (Specialized for Coding)

    +
    <?php
    +
    +require 'vendor/autoload.php';
    +
    +use OpenAI;
    +
    +$client = OpenAI::factory()
    +    ->withApiKey('choose-any-value')
    +    ->withBaseUri('https://qwen.ai.unturf.com/v1')
    +    ->make();
    +
    +$stream = $client->chat()->createStreamed([
    +    'model' => 'hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M',
    +    'messages' => [
    +        ['role' => 'user', 'content' => 'Give a Python Fizzbuzz solution in one line of code?'],
    +    ],
    +    'temperature' => 0.5,
    +    'max_tokens' => 150,
    +]);
    +
    +foreach ($stream as $response) {
    +    echo $response->choices[0]->delta->content ?? '';
    +}
    +
    + +

    Text-to-Speech Example

    +

    Generate audio speech from text using the TTS endpoint. The audio is saved as an MP3 file.

    + +
    <?php
    +
    +require 'vendor/autoload.php';
    +
    +use OpenAI;
    +
    +$client = OpenAI::factory()
    +    ->withApiKey('YOLO')
    +    ->withBaseUri('https://speech.ai.unturf.com/v1')
    +    ->make();
    +
    +$response = $client->audio()->speech([
    +    'model' => 'tts-1',
    +    'voice' => 'alloy',
    +    'input' => 'I think so therefore, Today is a wonderful day to build something people love!',
    +    'speed' => 0.9,
    +]);
    +
    +file_put_contents('speech.mp3', $response);
    +
    + + + + + + +
    + + + + + + diff --git a/python-examples.html b/python-examples.html index 42ee6c9..56dddb6 100644 --- a/python-examples.html +++ b/python-examples.html @@ -53,6 +53,8 @@
  • Node.js Examples
  • uncloseai.js Docs
  • Inference Setup
  • +
  • 🔗 All Languages
  • +
  • 📚 Book
  • diff --git a/ruby-examples.html b/ruby-examples.html new file mode 100644 index 0000000..bd2c7ee --- /dev/null +++ b/ruby-examples.html @@ -0,0 +1,282 @@ + + + + + + + + + Ruby Examples | uncloseai.com + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +

    uncloseai.

    +

    Ruby Examples - Free LLM & TTS AI Service

    +
    + +
    + +

    Ruby Examples

    +

    This page demonstrates how to use the uncloseai. API endpoints with Ruby using the official OpenAI Ruby gem. All examples use the same OpenAI-compatible API interface, making it easy to switch between different models and endpoints.

    + +

    Available Endpoints:

    + + +

    Ruby Client Installation

    +

    To install the official OpenAI gem for Ruby, add to your Gemfile or use gem install:

    +
    gem install openai
    + +

    Non-Streaming Examples

    +

    Non-streaming mode waits for the complete response before returning. This is simpler to use but provides no intermediate feedback during generation.

    + +

    Using Hermes (General Purpose)

    +
    require "openai"
    +
    +client = OpenAI::Client.new(
    +  access_token: "choose-any-value",
    +  uri_base: "https://hermes.ai.unturf.com/v1"
    +)
    +
    +response = client.chat(
    +  parameters: {
    +    model: "adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic",
    +    messages: [
    +      { role: "user", content: "Give a Python Fizzbuzz solution in one line of code?" }
    +    ],
    +    temperature: 0.5,
    +    max_tokens: 150
    +  }
    +)
    +
    +puts response.dig("choices", 0, "message", "content")
    +
    + +

    Using Qwen 3 Coder (Specialized for Coding)

    +
    require "openai"
    +
    +client = OpenAI::Client.new(
    +  access_token: "choose-any-value",
    +  uri_base: "https://qwen.ai.unturf.com/v1"
    +)
    +
    +response = client.chat(
    +  parameters: {
    +    model: "hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M",
    +    messages: [
    +      { role: "user", content: "Give a Python Fizzbuzz solution in one line of code?" }
    +    ],
    +    temperature: 0.5,
    +    max_tokens: 150
    +  }
    +)
    +
    +puts response.dig("choices", 0, "message", "content")
    +
    + +

    Streaming Examples

    +

    Streaming mode returns chunks of the response as they are generated, providing real-time feedback. This is ideal for interactive applications and long responses.

    + +

    Using Hermes (General Purpose)

    +
    require "openai"
    +
    +client = OpenAI::Client.new(
    +  access_token: "choose-any-value",
    +  uri_base: "https://hermes.ai.unturf.com/v1"
    +)
    +
    +client.chat(
    +  parameters: {
    +    model: "adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic",
    +    messages: [
    +      { role: "user", content: "Give a Python Fizzbuzz solution in one line of code?" }
    +    ],
    +    temperature: 0.5,
    +    max_tokens: 150,
    +    stream: proc do |chunk, _bytesize|
    +      content = chunk.dig("choices", 0, "delta", "content")
    +      print content if content
    +    end
    +  }
    +)
    +
    + +

    Using Qwen 3 Coder (Specialized for Coding)

    +
    require "openai"
    +
    +client = OpenAI::Client.new(
    +  access_token: "choose-any-value",
    +  uri_base: "https://qwen.ai.unturf.com/v1"
    +)
    +
    +client.chat(
    +  parameters: {
    +    model: "hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M",
    +    messages: [
    +      { role: "user", content: "Give a Python Fizzbuzz solution in one line of code?" }
    +    ],
    +    temperature: 0.5,
    +    max_tokens: 150,
    +    stream: proc do |chunk, _bytesize|
    +      content = chunk.dig("choices", 0, "delta", "content")
    +      print content if content
    +    end
    +  }
    +)
    +
    + +

    Text-to-Speech Example

    +

    Generate audio speech from text using the TTS endpoint. The audio is saved as an MP3 file.

    + +
    require "openai"
    +
    +client = OpenAI::Client.new(
    +  access_token: "YOLO",
    +  uri_base: "https://speech.ai.unturf.com/v1"
    +)
    +
    +response = client.audio.speech(
    +  parameters: {
    +    model: "tts-1",
    +    voice: "alloy",
    +    input: "I think so therefore, Today is a wonderful day to build something people love!",
    +    speed: 0.9
    +  }
    +)
    +
    +File.binwrite("speech.mp3", response)
    +
    + + + + + + +
    + + + + + + diff --git a/rust-examples.html b/rust-examples.html new file mode 100644 index 0000000..705d080 --- /dev/null +++ b/rust-examples.html @@ -0,0 +1,360 @@ + + + + + + + + + Rust Examples | uncloseai.com + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +

    uncloseai.

    +

    Rust Examples - Free LLM & TTS AI Service

    +
    + +
    + +

    Rust Examples

    +

    This page demonstrates how to use the uncloseai. API endpoints with Rust using the async-openai community library. All examples use the same OpenAI-compatible API interface, making it easy to switch between different models and endpoints.

    + +

    Available Endpoints:

    + + +

    Rust Client Installation

    +

    Add the async-openai crate to your Cargo.toml:

    +
    [dependencies]
    +async-openai = "0.24"
    +tokio = { version = "1", features = ["full"] }
    + +

    Non-Streaming Examples

    +

    Non-streaming mode waits for the complete response before returning. This is simpler to use but provides no intermediate feedback during generation.

    + +

    Using Hermes (General Purpose)

    +
    use async_openai::{
    +    config::OpenAIConfig,
    +    types::{ChatCompletionRequestMessage, CreateChatCompletionRequestArgs},
    +    Client,
    +};
    +
    +#[tokio::main]
    +async fn main() -> Result<(), Box<dyn std::error::Error>> {
    +    let config = OpenAIConfig::new()
    +        .with_api_key("choose-any-value")
    +        .with_api_base("https://hermes.ai.unturf.com/v1");
    +
    +    let client = Client::with_config(config);
    +
    +    let request = CreateChatCompletionRequestArgs::default()
    +        .model("adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic")
    +        .messages(vec![ChatCompletionRequestMessage::User(
    +            "Give a Python Fizzbuzz solution in one line of code?".into()
    +        )])
    +        .temperature(0.5)
    +        .max_tokens(150u32)
    +        .build()?;
    +
    +    let response = client.chat().create(request).await?;
    +
    +    println!("{}", response.choices[0].message.content.as_ref().unwrap());
    +
    +    Ok(())
    +}
    +
    + +

    Using Qwen 3 Coder (Specialized for Coding)

    +
    use async_openai::{
    +    config::OpenAIConfig,
    +    types::{ChatCompletionRequestMessage, CreateChatCompletionRequestArgs},
    +    Client,
    +};
    +
    +#[tokio::main]
    +async fn main() -> Result<(), Box<dyn std::error::Error>> {
    +    let config = OpenAIConfig::new()
    +        .with_api_key("choose-any-value")
    +        .with_api_base("https://qwen.ai.unturf.com/v1");
    +
    +    let client = Client::with_config(config);
    +
    +    let request = CreateChatCompletionRequestArgs::default()
    +        .model("hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M")
    +        .messages(vec![ChatCompletionRequestMessage::User(
    +            "Give a Python Fizzbuzz solution in one line of code?".into()
    +        )])
    +        .temperature(0.5)
    +        .max_tokens(150u32)
    +        .build()?;
    +
    +    let response = client.chat().create(request).await?;
    +
    +    println!("{}", response.choices[0].message.content.as_ref().unwrap());
    +
    +    Ok(())
    +}
    +
    + +

    Streaming Examples

    +

    Streaming mode returns chunks of the response as they are generated, providing real-time feedback. This is ideal for interactive applications and long responses.

    + +

    Using Hermes (General Purpose)

    +
    use async_openai::{
    +    config::OpenAIConfig,
    +    types::{ChatCompletionRequestMessage, CreateChatCompletionRequestArgs},
    +    Client,
    +};
    +use futures::StreamExt;
    +
    +#[tokio::main]
    +async fn main() -> Result<(), Box<dyn std::error::Error>> {
    +    let config = OpenAIConfig::new()
    +        .with_api_key("choose-any-value")
    +        .with_api_base("https://hermes.ai.unturf.com/v1");
    +
    +    let client = Client::with_config(config);
    +
    +    let request = CreateChatCompletionRequestArgs::default()
    +        .model("adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic")
    +        .messages(vec![ChatCompletionRequestMessage::User(
    +            "Give a Python Fizzbuzz solution in one line of code?".into()
    +        )])
    +        .temperature(0.5)
    +        .max_tokens(150u32)
    +        .build()?;
    +
    +    let mut stream = client.chat().create_stream(request).await?;
    +
    +    while let Some(result) = stream.next().await {
    +        match result {
    +            Ok(response) => {
    +                for choice in response.choices {
    +                    if let Some(content) = &choice.delta.content {
    +                        print!("{}", content);
    +                    }
    +                }
    +            }
    +            Err(err) => eprintln!("Error: {}", err),
    +        }
    +    }
    +
    +    Ok(())
    +}
    +
    + +

    Using Qwen 3 Coder (Specialized for Coding)

    +
    use async_openai::{
    +    config::OpenAIConfig,
    +    types::{ChatCompletionRequestMessage, CreateChatCompletionRequestArgs},
    +    Client,
    +};
    +use futures::StreamExt;
    +
    +#[tokio::main]
    +async fn main() -> Result<(), Box<dyn std::error::Error>> {
    +    let config = OpenAIConfig::new()
    +        .with_api_key("choose-any-value")
    +        .with_api_base("https://qwen.ai.unturf.com/v1");
    +
    +    let client = Client::with_config(config);
    +
    +    let request = CreateChatCompletionRequestArgs::default()
    +        .model("hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M")
    +        .messages(vec![ChatCompletionRequestMessage::User(
    +            "Give a Python Fizzbuzz solution in one line of code?".into()
    +        )])
    +        .temperature(0.5)
    +        .max_tokens(150u32)
    +        .build()?;
    +
    +    let mut stream = client.chat().create_stream(request).await?;
    +
    +    while let Some(result) = stream.next().await {
    +        match result {
    +            Ok(response) => {
    +                for choice in response.choices {
    +                    if let Some(content) = &choice.delta.content {
    +                        print!("{}", content);
    +                    }
    +                }
    +            }
    +            Err(err) => eprintln!("Error: {}", err),
    +        }
    +    }
    +
    +    Ok(())
    +}
    +
    + +

    Text-to-Speech Example

    +

    Generate audio speech from text using the TTS endpoint. The audio is saved as an MP3 file.

    + +
    use async_openai::{
    +    config::OpenAIConfig,
    +    types::{CreateSpeechRequestArgs, SpeechModel, Voice},
    +    Client,
    +};
    +use std::fs::File;
    +use std::io::Write;
    +
    +#[tokio::main]
    +async fn main() -> Result<(), Box<dyn std::error::Error>> {
    +    let config = OpenAIConfig::new()
    +        .with_api_key("YOLO")
    +        .with_api_base("https://speech.ai.unturf.com/v1");
    +
    +    let client = Client::with_config(config);
    +
    +    let request = CreateSpeechRequestArgs::default()
    +        .model(SpeechModel::Tts1)
    +        .voice(Voice::Alloy)
    +        .input("I think so therefore, Today is a wonderful day to build something people love!")
    +        .speed(0.9)
    +        .build()?;
    +
    +    let response = client.audio().speech(request).await?;
    +
    +    let mut file = File::create("speech.mp3")?;
    +    file.write_all(&response.bytes)?;
    +
    +    Ok(())
    +}
    +
    + + + + + + +
    + + + + + + diff --git a/swift-examples.html b/swift-examples.html new file mode 100644 index 0000000..9c2bc1a --- /dev/null +++ b/swift-examples.html @@ -0,0 +1,309 @@ + + + + + + + + + Swift Examples | uncloseai.com + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +

    uncloseai.

    +

    Swift Examples - Free LLM & TTS AI Service

    +
    + +
    + +

    Swift Examples

    +

    This page demonstrates how to use the uncloseai. API endpoints with Swift using the SwiftOpenAI community library. All examples use the same OpenAI-compatible API interface, making it easy to switch between different models and endpoints.

    + +

    Available Endpoints:

    + + +

    Swift Client Installation

    +

    Add SwiftOpenAI to your Package.swift dependencies:

    +
    dependencies: [
    +    .package(url: "https://github.com/jamesrochabrun/SwiftOpenAI", from: "3.8.5")
    +]
    + +

    Non-Streaming Examples

    +

    Non-streaming mode waits for the complete response before returning. This is simpler to use but provides no intermediate feedback during generation.

    + +

    Using Hermes (General Purpose)

    +
    import SwiftOpenAI
    +
    +let service = OpenAIServiceFactory.service(
    +    apiKey: "choose-any-value",
    +    baseURL: "https://hermes.ai.unturf.com/v1"
    +)
    +
    +let parameters = ChatCompletionParameters(
    +    messages: [.init(role: .user, content: .text("Give a Python Fizzbuzz solution in one line of code?"))],
    +    model: .custom("adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic"),
    +    temperature: 0.5,
    +    maxTokens: 150
    +)
    +
    +do {
    +    let completion = try await service.startChat(parameters: parameters)
    +    if let content = completion.choices.first?.message.content {
    +        print(content)
    +    }
    +} catch {
    +    print("Error: \(error)")
    +}
    +
    + +

    Using Qwen 3 Coder (Specialized for Coding)

    +
    import SwiftOpenAI
    +
    +let service = OpenAIServiceFactory.service(
    +    apiKey: "choose-any-value",
    +    baseURL: "https://qwen.ai.unturf.com/v1"
    +)
    +
    +let parameters = ChatCompletionParameters(
    +    messages: [.init(role: .user, content: .text("Give a Python Fizzbuzz solution in one line of code?"))],
    +    model: .custom("hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M"),
    +    temperature: 0.5,
    +    maxTokens: 150
    +)
    +
    +do {
    +    let completion = try await service.startChat(parameters: parameters)
    +    if let content = completion.choices.first?.message.content {
    +        print(content)
    +    }
    +} catch {
    +    print("Error: \(error)")
    +}
    +
    + +

    Streaming Examples

    +

    Streaming mode returns chunks of the response as they are generated, providing real-time feedback. This is ideal for interactive applications and long responses.

    + +

    Using Hermes (General Purpose)

    +
    import SwiftOpenAI
    +
    +let service = OpenAIServiceFactory.service(
    +    apiKey: "choose-any-value",
    +    baseURL: "https://hermes.ai.unturf.com/v1"
    +)
    +
    +let parameters = ChatCompletionParameters(
    +    messages: [.init(role: .user, content: .text("Give a Python Fizzbuzz solution in one line of code?"))],
    +    model: .custom("adamo1139/Hermes-3-Llama-3.1-8B-FP8-Dynamic"),
    +    temperature: 0.5,
    +    maxTokens: 150
    +)
    +
    +do {
    +    let stream = try await service.startStreamedChat(parameters: parameters)
    +    for try await chunk in stream {
    +        if let content = chunk.choices.first?.delta.content {
    +            print(content, terminator: "")
    +        }
    +    }
    +} catch {
    +    print("Error: \(error)")
    +}
    +
    + +

    Using Qwen 3 Coder (Specialized for Coding)

    +
    import SwiftOpenAI
    +
    +let service = OpenAIServiceFactory.service(
    +    apiKey: "choose-any-value",
    +    baseURL: "https://qwen.ai.unturf.com/v1"
    +)
    +
    +let parameters = ChatCompletionParameters(
    +    messages: [.init(role: .user, content: .text("Give a Python Fizzbuzz solution in one line of code?"))],
    +    model: .custom("hf.co/unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M"),
    +    temperature: 0.5,
    +    maxTokens: 150
    +)
    +
    +do {
    +    let stream = try await service.startStreamedChat(parameters: parameters)
    +    for try await chunk in stream {
    +        if let content = chunk.choices.first?.delta.content {
    +            print(content, terminator: "")
    +        }
    +    }
    +} catch {
    +    print("Error: \(error)")
    +}
    +
    + +

    Text-to-Speech Example

    +

    Generate audio speech from text using the TTS endpoint. The audio is saved as an MP3 file.

    + +
    import SwiftOpenAI
    +import Foundation
    +
    +let service = OpenAIServiceFactory.service(
    +    apiKey: "YOLO",
    +    baseURL: "https://speech.ai.unturf.com/v1"
    +)
    +
    +let parameters = AudioSpeechParameters(
    +    model: .tts1,
    +    input: "I think so therefore, Today is a wonderful day to build something people love!",
    +    voice: .alloy,
    +    speed: 0.9
    +)
    +
    +do {
    +    let audioData = try await service.createSpeech(parameters: parameters)
    +    let fileURL = FileManager.default.temporaryDirectory.appendingPathComponent("speech.mp3")
    +    try audioData.write(to: fileURL)
    +    print("Audio saved to: \(fileURL)")
    +} catch {
    +    print("Error: \(error)")
    +}
    +
    + + + + + + +
    + + + + + + diff --git a/uncloseai-js.html b/uncloseai-js.html index 11030f0..ebc3208 100644 --- a/uncloseai-js.html +++ b/uncloseai-js.html @@ -53,6 +53,8 @@
  • Node.js Examples
  • uncloseai.js Docs
  • Inference Setup
  • +
  • 🔗 All Languages
  • +
  • 📚 Book