claude-api

claude-api

ClaudeAI for Slack、claude.ai

Stars: 164

Visit
 screenshot

claude-api is a web conversation library for ClaudeAI implemented in GoLang. It provides functionalities to interact with ClaudeAI for web-based conversations. Users can easily integrate this library into their Go projects to enable chatbot capabilities and handle conversations with ClaudeAI. The library includes features for sending messages, receiving responses, and managing chat sessions, making it a valuable tool for developers looking to incorporate AI-powered chatbots into their applications.

README:

WEB ClaudeAI for GoLang

Web Conversation Library for ClaudeAI. link

Usage

go get github.com/bincooo/claude-api@[commit]
const (
	cookies = "xxx"
)

fun main() {
	session := emit.NewJa3Session("http://127.0.0.1:7890", 180*time.Second)
	options, err := NewDefaultOptions(cookies, "")
	if err != nil {
		t.Fatal(err)
	}

	timeout, cancel := context.WithTimeout(context.Background(), 180*time.Second)
	defer cancel()

	chat, err := New(options)
	if err != nil {
		t.Fatal(err)
	}

	chat.Client(session)
	partialResponse, err := chat.Reply(timeout, "hi ~ who are you?", nil)
	if err != nil {
		t.Fatal(err)
	}

	echo(t, partialResponse)
	chat.Delete()
}

func echo(t *testing.T, response chan PartialResponse) {
	content := ""
	for {
		message, ok := <-response
		if !ok {
			break
		}

		if message.Error != nil {
			t.Fatal(message.Error)
		}

		t.Log(message.Text)
		t.Log("===============")
		content += message.Text
	}

	t.Log(content)
}

For Tasks:

Click tags to check more tools for each tasks

For Jobs:

Alternative AI tools for claude-api

Similar Open Source Tools

For similar tasks

For similar jobs