{"id":29188474,"url":"https://github.com/atopx/teiclient","last_synced_at":"2025-07-01T22:35:45.282Z","repository":{"id":294070495,"uuid":"985893692","full_name":"atopx/teiclient","owner":"atopx","description":"go client for text-embedding-inference (https://github.com/huggingface/text-embeddings-inference)","archived":false,"fork":false,"pushed_at":"2025-05-18T19:16:04.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-18T19:38:07.407Z","etag":null,"topics":["rerank","tei","text-embedding","text-embeddings-inference"],"latest_commit_sha":null,"homepage":"https://github.com/huggingface/text-embeddings-inference","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atopx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-18T18:32:04.000Z","updated_at":"2025-05-18T19:16:07.000Z","dependencies_parsed_at":"2025-05-18T19:48:11.164Z","dependency_job_id":null,"html_url":"https://github.com/atopx/teiclient","commit_stats":null,"previous_names":["atopx/teiclient"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/atopx/teiclient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atopx%2Fteiclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atopx%2Fteiclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atopx%2Fteiclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atopx%2Fteiclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atopx","download_url":"https://codeload.github.com/atopx/teiclient/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atopx%2Fteiclient/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263047323,"owners_count":23405277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rerank","tei","text-embedding","text-embeddings-inference"],"created_at":"2025-07-01T22:35:44.558Z","updated_at":"2025-07-01T22:35:45.228Z","avatar_url":"https://github.com/atopx.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# text-embeddings-inference go client\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/atopx/teiclient)](https://pkg.go.dev/github.com/atopx/teiclient)\n\nAn elegant, idiomatic Go client for the Hugging Face Text Embeddings Inference (TEI) service, supporting both HTTP REST and gRPC transports. Simplify your workflow by choosing the interface that best fits your use case.\n\n---\n\n## Repository Structure\n\n```\n.\n├── proto/                   # Auto-generated protobuf code\n│   ├── tei.proto           # gRPC + HTTP OpenAPI definitions\n│   ├── tei.pb.go           # Go structs + HTTP client interfaces\n│   └── tei_grpc.pb.go      # Go gRPC client stubs\n├── teiapi/                 # HTTP REST client implementation\n│   └── api.go              # HTTP client wrapper\n└── teigrpc/                # gRPC client implementation\n    └── grpc.go             # gRPC client wrapper\n```\n\n---\n\n## Features\n\n* **Dual Transport**: Use HTTP REST or gRPC with the same protobuf definitions.\n* **Unified API**: Access Info, Embed, Predict, Rerank, Tokenize, and Decode endpoints.\n* **Streaming Support**: Bidirectional streaming for large or batched operations.\n* **Context-aware**: Pass `context.Context` to manage timeouts and cancellations.\n* **Lightweight**: Zero external dependencies beyond `grpc-go` and the standard library.\n\n---\n\n## Installation\n\n```bash\ngo get -u github.com/atopx/teiclient\n```\n\n---\n\n## HTTP REST Client Quick Start\n\u003e [OpenAPI Specification](https://huggingface.github.io/text-embeddings-inference/#/ )\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"time\"\n\n    \"github.com/atopx/teiclient/teiapi\"\n    \"github.com/atopx/teiclient/proto\"\n)\n\nfunc main() {\n    // 1. Create HTTP client\n    client := teiapi.New(\"http://localhost:8080\", 30*time.Second)\n\n    // 2. Info\n    infoResp, err := client.Info(context.Background(), \u0026proto.InfoRequest{})\n    if err != nil {\n        panic(err)\n    }\n    fmt.Println(\"Model ID:\", infoResp.ModelId)\n\n    // 3. Embed\n    embedReq := \u0026proto.EmbedRequest{Inputs: \"Hello, HTTP!\", Normalize: true}\n    embedResp, err := client.Embed(context.Background(), embedReq)\n    if err != nil {\n        panic(err)\n    }\n    fmt.Printf(\"Embedding length: %d\\n\", len(embedResp.Embeddings))\n}\n```\n\n---\n\n## gRPC Client Quick Start\n\u003e [proto definition](./proto/tei.proto)\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"time\"\n\n    \"github.com/atopx/teiclient/teigrpc\"\n    \"github.com/atopx/teiclient/proto\"\n)\n\nfunc main() {\n    // 1. Create gRPC client\n    client, err := teigrpc.New(\"localhost:50051\")\n    if err != nil {\n        panic(err)\n    }\n    defer client.Close()\n\n    // 2. Rerank\n    rerankReq := \u0026proto.RerankRequest{\n        Query:      \"search term\",\n        Texts:      []string{\"A\", \"B\"},\n        ReturnText: true,\n    }\n    rerankResp, err := client.Rerank(context.Background(), rerankReq)\n    if err != nil {\n        panic(err)\n    }\n    for _, r := range rerankResp.Ranks {\n        fmt.Printf(\"#%d: %s (%.2f)\\n\", r.Index, r.Text, r.Score)\n    }\n}\n```\n\n---\n\n## Common API Reference\n\nAll methods correspond to `tei.proto` definitions. Key interfaces:\n\n* HTTP client in `teiapi/api.go` uses methods:\n\n  * `Info(ctx, *InfoRequest) (*InfoResponse, error)`\n  * `Embed(ctx, *EmbedRequest) (*EmbedResponse, error)`\n  * `Predict(ctx, *PredictRequest) (*PredictResponse, error)`\n  * `Rerank(ctx, *RerankRequest) (*RerankResponse, error)`\n  * `Tokenize(ctx, *EncodeRequest) (*EncodeResponse, error)`\n  * `Decode(ctx, *DecodeRequest) (*DecodeResponse, error)`\n\n* gRPC client in `teigrpc/grpc.go` exposes:\n\n  * `Info`, `Embed`, `EmbedStream`, `Predict`, `PredictStream`, `Rerank`, `RerankStream`, `Tokenize`, `Decode`, etc.\n\nRefer to the GoDoc for full signatures and streaming variants.\n\n---\n\n## Contributing\n\nContributions, issues, and feature requests are welcome! Please open a GitHub issue or submit a pull request.\n\n---\n\n## License\n\nMIT. See [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatopx%2Fteiclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatopx%2Fteiclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatopx%2Fteiclient/lists"}