{"id":35198090,"url":"https://github.com/lzjever/lexilux","last_synced_at":"2026-01-26T21:21:36.860Z","repository":{"id":330933539,"uuid":"1124487928","full_name":"lzjever/lexilux","owner":"lzjever","description":"Unified LLM API client library for Python. Simple API for Chat, Embedding, Rerank, and Tokenizer. OpenAI-compatible with streaming support and unified usage tracking.","archived":false,"fork":false,"pushed_at":"2026-01-24T19:01:10.000Z","size":1576,"stargazers_count":41,"open_issues_count":0,"forks_count":18,"subscribers_count":23,"default_branch":"main","last_synced_at":"2026-01-24T21:35:17.506Z","etag":null,"topics":["api-client","chat-api","document-ranking","embedding","function-api","llm","openai-api","openai-compatible","python","rerank","reranker","semantic-search","streaming","tokenizer"],"latest_commit_sha":null,"homepage":"https://lexilux.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lzjever.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-29T05:30:20.000Z","updated_at":"2026-01-24T19:01:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/lzjever/lexilux","commit_stats":null,"previous_names":["lzjever/lexilux"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/lzjever/lexilux","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzjever%2Flexilux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzjever%2Flexilux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzjever%2Flexilux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzjever%2Flexilux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lzjever","download_url":"https://codeload.github.com/lzjever/lexilux/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzjever%2Flexilux/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28788368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T21:13:08.818Z","status":"ssl_error","status_checked_at":"2026-01-26T21:13:08.448Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["api-client","chat-api","document-ranking","embedding","function-api","llm","openai-api","openai-compatible","python","rerank","reranker","semantic-search","streaming","tokenizer"],"created_at":"2025-12-29T08:25:08.658Z","updated_at":"2026-01-26T21:21:36.851Z","avatar_url":"https://github.com/lzjever.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lexilux\n\n[![PyPI version](https://img.shields.io/pypi/v/lexilux.svg)](https://pypi.org/project/lexilux/)\n[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)\n[![License](https://img.shields.io/badge/license-Apache%202.0-green.svg)](LICENSE)\n[![Documentation](https://readthedocs.org/projects/lexilux/badge/?version=latest)](https://lexilux.readthedocs.io)\n[![CI](https://github.com/lzjever/lexilux/workflows/CI/badge.svg)](https://github.com/lzjever/lexilux/actions)\n[![codecov](https://codecov.io/gh/lzjever/lexilux/branch/main/graph/badge.svg)](https://codecov.io/gh/lzjever/lexilux)\n\n**Lexilux** is a unified LLM API client library that makes calling Chat, Embedding, Rerank, and Tokenizer APIs as simple as calling a function.\n\n## Features\n\n- **Function-like API**: Call APIs like functions (`chat(\"hi\")`, `embed([\"text\"])`)\n- **Streaming Support**: Built-in streaming for Chat with usage tracking\n- **Unified Usage**: Consistent usage statistics across all APIs\n- **Flexible Input**: Support multiple input formats (string, list, dict)\n- **OpenAI-Compatible**: Works with OpenAI-compatible APIs\n- **Automatic Retry**: Built-in retry logic with exponential backoff\n- **Connection Pooling**: HTTP connection pooling for better performance\n- **Exception Hierarchy**: Comprehensive exception system with error codes\n- **Function Calling**: OpenAI-compatible function/tool calling support\n- **Multimodal Support**: Vision capabilities with image inputs\n- **Async Support**: Full async/await API for concurrent operations\n\n## Installation\n\n### Quick Install\n\n```bash\npip install lexilux\n```\n\n### With Tokenizer Support\n\n```bash\npip install lexilux[tokenizer]\n```\n\n### Development Setup with uv (Recommended)\n\nThis project uses [uv](https://github.com/astral-sh/uv) for fast dependency management.\n\n```bash\n# Install uv\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n\n# For active development\nmake dev-install\n\n# Or manually with uv\nuv sync --group docs --all-extras\n```\n\n### Legacy pip Setup\n\n```bash\npip install -e \".[dev]\"\n```\n\n## Quick Start\n\n### Basic Chat\n\n```python\nfrom lexilux import Chat\n\nchat = Chat(base_url=\"https://api.example.com/v1\", api_key=\"your-key\", model=\"gpt-4\")\nresult = chat(\"Hello, world!\")\nprint(result.text)\nprint(result.usage.total_tokens)\n```\n\n### Streaming\n\n```python\nfor chunk in chat.stream(\"Tell me a joke\"):\n    print(chunk.delta, end=\"\", flush=True)\n    if chunk.done:\n        print(f\"\\nTokens: {chunk.usage.total_tokens}\")\n```\n\n### Error Handling\n\n```python\nfrom lexilux import LexiluxError, AuthenticationError, RateLimitError\n\ntry:\n    result = chat(\"Hello, world!\")\nexcept AuthenticationError as e:\n    print(f\"Authentication failed: {e.message}\")\nexcept RateLimitError as e:\n    if e.retryable:\n        print(f\"Rate limited: {e.message}\")\nexcept LexiluxError as e:\n    print(f\"Error: {e.code} - {e.message}\")\n```\n\n### Function Calling\n\n```python\nfrom lexilux import Chat, FunctionTool\n\nget_weather = FunctionTool(\n    name=\"get_weather\",\n    description=\"Get weather for a location\",\n    parameters={\n        \"type\": \"object\",\n        \"properties\": {\n            \"location\": {\"type\": \"string\", \"description\": \"City name\"},\n            \"unit\": {\"type\": \"string\", \"enum\": [\"celsius\", \"fahrenheit\"]}\n        },\n        \"required\": [\"location\"]\n    }\n)\n\nresult = chat(\"What's the weather in Paris?\", tools=[get_weather])\nif result.has_tool_calls:\n    for tool_call in result.tool_calls:\n        print(f\"Calling: {tool_call.name}\")\n        print(f\"Arguments: {tool_call.get_arguments()}\")\n```\n\n### Async\n\n```python\nimport asyncio\nfrom lexilux import Chat\n\nasync def main():\n    chat = Chat(base_url=\"...\", api_key=\"...\", model=\"gpt-4\")\n    result = await chat.a(\"Hello, async world!\")\n    print(result.text)\n\nasyncio.run(main())\n```\n\n## Documentation\n\nFull documentation available at: [lexilux.readthedocs.io](https://lexilux.readthedocs.io)\n\n## Examples\n\nCheck out the `examples/` directory for practical examples:\n\n- `examples/01_hello_world.py` - Basic chat completion\n- `examples/02_system_message.py` - Using system messages\n- `examples/10_streaming.py` - Streaming chat\n- `examples/11_conversation.py` - Multi-turn conversations\n- `examples/12_chat_params.py` - Custom chat parameters\n- `examples/20_embedding.py` - Text embedding\n- `examples/21_rerank.py` - Document reranking\n- `examples/22_tokenizer.py` - Tokenization\n- `examples/30_function_calling.py` - Function calling\n- `examples/31_multimodal.py` - Vision capabilities\n- `examples/32_async.py` - Async operations\n- `examples/40_chat_history.py` - History management\n- `examples/41_auto_continue.py` - Continue cut-off responses\n- `examples/42_error_handling.py` - Error handling patterns\n- `examples/43_custom_formatting.py` - Custom response formatting\n\nRun examples:\n\n```bash\npython examples/01_hello_world.py\n```\n\n## Testing\n\n```bash\n# Run unit tests\nmake test\n\n# Run integration tests\nmake test-integration\n\n# Run with coverage\nmake test-cov\n\n# Run linting\nmake lint\n\n# Format code\nmake format\n```\n\nBuild documentation locally:\n\n```bash\ncd docs \u0026\u0026 make html\n```\n\n## About Agentsmith\n\n**Lexilux** is part of the **Agentsmith** open-source ecosystem. Agentsmith is a ToB AI agent and algorithm development platform, currently deployed in multiple highway management companies, securities firms, and regulatory agencies in China. The Agentsmith team is gradually open-sourcing the platform by removing proprietary code and algorithm modules, as well as enterprise-specific customizations, while decoupling the system for modular use by the open-source community.\n\n### Agentsmith Open-Source Projects\n\n- **[Varlord](https://github.com/lzjever/varlord)** - Configuration management library\n- **[Routilux](https://github.com/lzjever/routilux)** - Event-driven workflow orchestration\n- **[Serilux](https://github.com/lzjever/serilux)** - Flexible serialization framework\n- **[Lexilux](https://github.com/lzjever/lexilux)** - Unified LLM API client library\n\n## License\n\nLexilux is licensed under the **Apache License 2.0**. See [LICENSE](LICENSE) for details.\n\n## Links\n\n- **PyPI**: [pypi.org/project/lexilux](https://pypi.org/project/lexilux)\n- **Documentation**: [lexilux.readthedocs.io](https://lexilux.readthedocs.io)\n- **GitHub**: [github.com/lzjever/lexilux](https://github.com/lzjever/lexilux)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzjever%2Flexilux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flzjever%2Flexilux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzjever%2Flexilux/lists"}