Skip to content

Commit

Permalink
Merge pull request #113 from jamesrochabrun/jroch-more-models
Browse files Browse the repository at this point in the history
DeepSeek demo
  • Loading branch information
jamesrochabrun authored Feb 2, 2025
2 parents d48aa1b + 549cb00 commit c581d02
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ An open-source Swift package designed for effortless interaction with OpenAI's p
- [Vector store File](#vector-store-file)
- [Vector store File Batch](#vector-store-file-batch)


## Getting an API Key

⚠️ **Important**
Expand Down Expand Up @@ -105,6 +104,7 @@ SwiftOpenAI supports various providers that are OpenAI-compatible, including but
- [Ollama](#ollama)
- [Groq](#groq)
- [OpenRouter](#openRouter)
- [DeepSeek](#deepseek)
- [AIProxy](#aiproxy)

Check OpenAIServiceFactory for convenience initializers that you can use to provide custom URLs.
Expand Down Expand Up @@ -3257,10 +3257,10 @@ For Supported API's using Groq visit its [documentation](https://console.groq.co

## OpenRouter

[OpenRouter](https://openrouter.ai/docs/quick-start) provides an OpenAI-compatible completion API to 314 models & providers that you can call directly, or using the OpenAI SDK. Additionally, some third-party SDKs are available.

<img width="734" alt="Image" src="https://github.com/user-attachments/assets/2d658d07-0b41-4b5f-a094-ec7856f6fe98" />

[OpenRouter](https://openrouter.ai/docs/quick-start) provides an OpenAI-compatible completion API to 314 models & providers that you can call directly, or using the OpenAI SDK. Additionally, some third-party SDKs are available.

```swift

// Creating the service
Expand All @@ -3274,12 +3274,38 @@ let servcie = OpenAIServiceFactory.service(apiKey: apiKey,
"X-Title": "<YOUR_SITE_NAME>" // Optional. Site title for rankings on openrouter.ai.
])

// Making a
// Making a request

let prompt = "What is the Manhattan project?"
let parameters = ChatCompletionParameters(messages: [.init(role: .user, content: .text(prompt))], model: .custom("deepseek/deepseek-r1:free"))
let stream = service.startStreamedChat(parameters: parameters)
```

For more inofrmation about the `OpenRouter` api visit its [documentation](https://openrouter.ai/docs/quick-start).

## DeepSeek

![Image](https://github.com/user-attachments/assets/7733f011-691a-4de7-b715-c090e3647304)

The [DeepSeek](https://api-docs.deepseek.com/) API uses an API format compatible with OpenAI. By modifying the configuration, you can use SwiftOpenAI to access the DeepSeek API.

```swift
// Creating the service

let apiKey = "your_api_key"
let service = OpenAIServiceFactory.service(
apiKey: apiKey,
overrideBaseURL: "https://api.deepseek.com")

// Making a request

let prompt = "What is the Manhattan project?"
let parameters = ChatCompletionParameters(messages: [.init(role: .user, content: .text(prompt))], model: .custom("deepseek-reasoner"))
let stream = service.startStreamedChat(parameters: parameters)
```

For more inofrmation about the `DeepSeek` api visit its [documentation](https://api-docs.deepseek.com).

## Gemini

<img width="982" alt="Screenshot 2024-11-12 at 10 53 43 AM" src="https://github.com/user-attachments/assets/cebc18fe-b96d-4ffe-912e-77d625249cf2">
Expand Down

0 comments on commit c581d02

Please sign in to comment.