Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rabilrbl/deepseek-api
Unofficial API Wrapper for Deepseek (chat.deepseek.com)
https://github.com/rabilrbl/deepseek-api
deepseeek deepseek-chat deepseek-coder deepseek-llm
Last synced: 7 days ago
JSON representation
Unofficial API Wrapper for Deepseek (chat.deepseek.com)
- Host: GitHub
- URL: https://github.com/rabilrbl/deepseek-api
- Owner: rabilrbl
- License: other
- Created: 2023-11-09T18:42:43.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-01-05T17:04:21.000Z (10 months ago)
- Last Synced: 2024-05-02T02:55:10.628Z (6 months ago)
- Topics: deepseeek, deepseek-chat, deepseek-coder, deepseek-llm
- Language: Python
- Homepage:
- Size: 101 KB
- Stars: 14
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Deepseek coder Reverse Engineered API Wrapper
Unofficial API Wrapper for Deepseek (chat.deepseek.com) in Python. This is a reverse-engineered API for the Deepseek coder and Deepseek code chatbots. This API is not affiliated with Deepseek in any way.
## Installation
```bash
pip install git+https://github.com/rabilrbl/deepseek-api.git
```## Usage
### Asynchronous CLI Example
```python
import asyncio
import os
from deepseek_api import DeepseekAPI
from dotenv import load_dotenvload_dotenv()
async def main():
email = os.environ.get("DEEPSEEK_EMAIL")
password = os.environ.get("DEEPSEEK_PASSWORD")async with DeepseekAPI(
email=email,
password=password,
save_login=True, # save login credentials to login.json
model_class="deepseek_code", # Choose from "deepseek_chat" or "deepseek_code"
) as app:
print(
"""
Usage:
- Type 'new' to start a new chat.
- Type 'exit' to exit.
Start chatting!
"""
)while True:
message = input("> ")if message == "exit":
break
elif message == "new":
await app.new_chat()
continueasync for chunk in app.chat(message):
try:
# keep printing in one line
print(chunk["choices"][0]["delta"]["content"], end="")
except KeyError as ke:
print(ke)
print()if __name__ == "__main__":
asyncio.run(main())
```### Synchonous CLI Example
```python
import os
from deepseek_api import SyncDeepseekAPI
from dotenv import load_dotenvload_dotenv()
def main():
email = os.environ.get("DEEPSEEK_EMAIL")
password = os.environ.get("DEEPSEEK_PASSWORD")app = SyncDeepseekAPI(
email=email,
password=password,
save_login=True, # save login credentials to login.json
model_class="deepseek_code", # Choose from "deepseek_chat" or "deepseek_code"
)print(
"""
Usage:
- Type 'new' to start a new chat.
- Type 'exit' to exit.
Start chatting!
"""
)while True:
message = input("> ")if message == "exit":
# close the app
app.close()
break
elif message == "new":
app.new_chat()
continueresponse = app.chat(message)
for chunk in response:
try:
# keep printing in one line
print(chunk["choices"][0]["delta"]["content"], end="")
except KeyError as ke:
print(ke)
print()if __name__ == "__main__":
main()
```## License
[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)
## Disclaimer
This project is not affiliated with Deepseek in any way. Use at your own risk. This project was created for educational purposes only.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.