Skip to content

Commit

Permalink
Update fern/pages/v2/text-generation/chat-api.mdx
Browse files Browse the repository at this point in the history
Co-authored-by: Meor Amer <[email protected]>
Signed-off-by: billytrend-cohere <[email protected]>
  • Loading branch information
billytrend-cohere and mrmer1 authored Sep 26, 2024
1 parent 71dcb69 commit be694fb
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions fern/pages/v2/text-generation/chat-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,36 @@ res = co.chat(
print(res.message.content[0].text) # "The Ultimate Guide to API Design: Best Practices for Building Robust and Scalable APIs"
```
```java JAVA
public class ChatPost {
public static void main(String[] args) {
Cohere cohere = Cohere.builder().token("<YOUR API KEY>").build();

NonStreamedChatResponse response = cohere.chat(
ChatRequest.builder()
.model("command-r-plus-08-2024")
.message("Write a title for a blog post about API design. Only output the title text.")
)

System.out.println(response); // "The Art of API Design: Crafting Elegant and Powerful Interfaces"
}
package chatv2post;

import com.cohere.api.Cohere;
import com.cohere.api.resources.v2.requests.V2ChatRequest;
import com.cohere.api.types.*;
import java.util.List;

public class Default {
public static void main(String[] args) {
Cohere cohere = Cohere.builder().token("<<apiKey>>").clientName("snippet").build();

ChatResponse response =
cohere.v2()
.chat(
V2ChatRequest.builder()
.model("command-r-plus")
.messages(
List.of(
ChatMessageV2.user(
UserMessage.builder()
.content(
UserMessageContent
.of("Hello world!"))
.build())))
.build());

System.out.println(response);
}
}

```
```typescript TYPESCRIPT
const { CohereClientV2 } = require('cohere-ai');
Expand Down

0 comments on commit be694fb

Please sign in to comment.