Skip to content

Quick Start

JuheNext, like the OpenAI API, provides a simple interface that allows you to use state-of-the-art AI models for natural language processing, image generation, semantic search, and speech recognition. Follow this guide to learn how to generate human-like responses to natural language prompts, create vector embeddings for semantic search, and generate images from text descriptions.

First, you can use JuheNext like this:

curl

curl
curl "https://api.juheai.top/v1/chat/completions" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer sk-xxx" \
    -d '{
        "model": "gpt-4o",
        "messages": [
            {
                "role": "system",
                "content": "You are a helpful assistant."
            },
            {
                "role": "user",
                "content": "Hello"
            }
        ]
    }'

You will receive a response like this:

curl
{"id":"chatcmpl-9wk81HBBspfBfOcKnaTtsuELgfXen","model":"gpt-4o","object":"chat.completion","created":1723787416,"choices":[{"index":0,"message":{"role":"assistant","content":"Hello! How can I help you today?"},"finish_reason":"stop"}],"usage":{"prompt_tokens":18,"completion_tokens":9,"total_tokens":27}}

python

python
import requests
import json

url = "https://api.juheai.top/v1/chat/completions"

payload = json.dumps({
   "model": "gpt-4o",
   "messages": [
      {
         "role": "system",
         "content": "You are a helpful assistant."
      },
      {
         "role": "user",
         "content": "Hello"
      }
   ],
   "stream": False
})
headers = {
   'Accept': 'application/json',
   'Authorization': 'Bearer sk-xxx',
   'User-Agent': 'Apifox/1.0.0 (https://apifox.com)',
   'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

You will receive a response like this:

python
{
  "id": "chatcmpl-9wkE9z3XjWjBGMtfuCzt4cXu3D48J",
  "object": "chat.completion",
  "created": 1723787749,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?",
        "refusal": null
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 18,
    "completion_tokens": 9,
    "total_tokens": 27
  },
  "system_fingerprint": "fp_3aa7262c27"
}

You can also use the official library provided by OpenAI:

Install the openai library

pip install openai
python
from openai import OpenAI
client = OpenAI(
    # This is the default and can be omitted
    base_url="https://api.juheai.top/v1",
    api_key="sk-xxx",
)

completion = client.chat.completions.create(
  model="gpt-4o",
  messages=[
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ]
)

print(completion.choices[0].message)