开发喵星球

# 开发喵AI使用说明(更新中。。。)

一、接口调用

1.1 接口地址(通用)

https://kfmapi.natappvip.cc、https://api.kaifamiao.com

1.2、多模型调用方法

API地址/ai/模型/v1/chat/completions

https://kfmapi.natappvip.cc/ai/baidu/v1/chat/completions
https://kfmapi.natappvip.cc/ai/hunyuan/v1/chat/completions
https://kfmapi.natappvip.cc/ai/tongyi/v1/chat/completions

1.3 vip地址

API地址/vip

https://kfmapi.natappvip.cc/vip/

1.4 SVIP接口

AP I地址/svip

https://kfmapi.natappvip.cc/svip

1.5 定制地址

1.6 兼容OpenAI

API地址/v1

https://kfmapi.natappvip.cc/v1/chat/completions

二、支持模型

模型 厂商 价格 地址
gpt4-o,gpt-3.5-turbo
gpt-4o
claude-3-5-sonnet-20241022
gemini-1.5-flash
glm-4-plus

llama-3.1-sonar

Model Parameter Count Context Length Model Type
llama-3.1-sonar-small-128k-online 8B 127,072 Chat Completion
llama-3.1-sonar-large-128k-online 70B 127,072 Chat Completion
llama-3.1-sonar-huge-128k-online 405B 127,072 Chat Completion

三、调用示例

curl

curl -X POST 'https://kfmapi.natappvip.cc/v1/chat/completions' \
-H 'Authorization: Bearer you-key' \
-H 'Content-Type: application/json' \
-d '{
    "model":"gpt-4o",
    "messages": [
        {
            "role": "user",
            "content": "来一个只有程序员能听懂的笑话"
        }
    ],
    "stream": true
}'

注意要加Bearer,地址需要完整地址

Python Openai接口

from openai import OpenAI

client = OpenAI(
    base_url="https://kfmapi.natappvip.cc/v1",
    api_key="you-key"
)

stream = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "你是哪个模型",
        }
    ],
    model="gpt-4o",
    stream=True,
)
for chunk in stream:
    print(f"{chunk}\n")

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public class OpenAIStreamingExample {
    public static void main(String[] args) {
        String apiKey = "ak_147258wxHaoHaoyzab";
        String baseUrl = "https://kfmapi.natappvip.cc/v1";
        String endpoint = baseUrl + "/chat/completions";

        String requestBody = """
                {
                    "messages": [
                        {
                            "role": "user",
                            "content": "你是哪个模型"
                        }
                    ],
                    "model": "gpt-4o",
                    "stream": true
                }
                """;

        HttpClient client = HttpClient.newBuilder()
                .connectTimeout(Duration.ofSeconds(10))
                .build();

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(endpoint))
                .header("Content-Type", "application/json")
                .header("Authorization", "Bearer " + apiKey)
                .POST(HttpRequest.BodyPublishers.ofString(requestBody))
                .build();

        try {
            HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());

            if (response.statusCode() == 200) {
                System.out.println("Response: " + response.body());
            } else {
                System.out.println("Error: " + response.statusCode() + " " + response.body());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

四、兼容其他软件

NextChat

image-20250103111447008

Cursor

image-20250103110030193

chatbox

image-20250103111253923

   
分类:未分类 作者:开发喵 发表于:2025-01-08 21:25:23 阅读量:30
  >>


powered by kaifamiao