Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auth fail 401 #41

Closed
YP1X opened this issue Apr 4, 2024 · 7 comments
Closed

auth fail 401 #41

YP1X opened this issue Apr 4, 2024 · 7 comments

Comments

@YP1X
Copy link

YP1X commented Apr 4, 2024

auth fail 401
Is this still working?

@Vinlic
Copy link
Member

Vinlic commented Apr 4, 2024

@YP1X
I confirm that the service is working normally, please check whether your token is wrong.

@YP1X
Copy link
Author

YP1X commented Apr 4, 2024

Error: Not found because of proxy error: Error: Client network socket disconnected before secure TLS connection was established (Status Code: 404)
I believe token is right this time.

@YP1X
Copy link
Author

YP1X commented Apr 4, 2024

I am using botpress cloud platform to build bots.

@Vinlic
Copy link
Member

Vinlic commented Apr 4, 2024

@YP1X Can you provide a screenshot of the container log of kimi-free-api? I connected through Dify and found no problem.

@YP1X
Copy link
Author

YP1X commented Apr 4, 2024

404 didn't reoccur. I am not a dev so maybe it's a coding problem.
code:

const kimi_API_KEY = env.kimiFreeKey;

const data = {
    // 模型名称随意填写,如果不希望输出检索过程模型名称请包含silent_search
    "model": "kimi",
    "messages": [
        {
            "role": "user",
            "content": `${workflow.message}`
        }
    ],
    // 是否开启联网搜索,默认false
    "use_search": true,
    // 如果使用SSE流请设置为true,默认false
    "stream": false
}

async function getKimiMessage() {
  try {
    const response = await axios.post('https://api.moonshot.cn/v1/chat/completions', data, {
      headers: {
        Authorization: `Bearer ${kimi_API_KEY}`,
        'Content-Type': 'application/json',
      },
    });

    workflow.response = response.data.choices[0].message.content;
    return workflow.response;
  } catch (error) {
    console.error(error);
    throw error;
  }
}

await getKimiMessage()
  .then((message) => {
    console.log('Kimi message:', message);
  })
  .catch((error) => {
    console.error('Error:', error);
  });

Screenshot (1150)

@Vinlic
Copy link
Member

Vinlic commented Apr 4, 2024

@YP1X You may have mistaken the function of kimi-free-api. This is not the official API channel of kimi moonshot ai, but reverses the kimi.ai page function and converts it into an API interface compatible with openai. If you want to use the official moonshot ai interface, please go to https://platform.moonshot.cn/. If you want to use kimi-free-api, please deploy the service yourself and change the proxy address and port, and then change API_KEY to refresh_token.

@YP1X
Copy link
Author

YP1X commented Apr 5, 2024

I may try Dify. THX for your note.

@YP1X YP1X closed this as completed Apr 5, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants