POST
javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 const axios = require('axios'); const fs = require('fs'); const path = require('path'); // helper function to help you convert your local images into base64 format async function toB64(imgPath) { const data = fs.readFileSync(path.resolve(imgPath)); return Buffer.from(data).toString('base64'); } const api_key = "YOUR API-KEY"; const url = "https://api.segmind.com/v1/claude-3.5-sonnet"; const data = { "messages": [ { "role": "user", "content" : "tell me a joke on cats" }, { "role": "assistant", "content" : "here is a joke about cats..." }, { "role": "user", "content" : "now a joke on dogs" }, ] }; (async function() { try { const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } }); console.log(response.data); } catch (error) { console.error('Error:', error.response.data); } })();
RESPONSE
application/json
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


messagesArray

An array of objects containing the role and content


rolestr

Could be "user", "assistant" or "system".


contentstr

A string containing the user's query or the assistant's response.

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

Claude 3.5 Sonnet

Claude 3.5 Sonnet is a state-of-the-art large language model (LLM) developed by Anthropic. It is part of the Claude 3.5 series, which builds upon the strengths of previous Claude models while introducing new capabilities. Claude 3.5 Sonnet represents a significant advancement in AI language models, combining speed, accuracy, and visual reasoning capabilities.

  • Improved Accuracy and Efficiency: Claude 3.5 Sonnet is better than previous versions at following instructions and completing requests thoughtfully. It can also perform these tasks more quickly.

  • Claude 3.5 Sonnet is particularly adept at visual reasoning tasks. This means it can interpret charts, graphs, and images with greater accuracy. It can also extract text from images, which is useful in fields like retail, logistics, and finance etc.

Claude 3.5 Sonnet's potential stretches across fields. It can transform education with interactive learning and personalized paths. Content creators can leverage it for writing and data visualization. Customer service gets a boost with smarter chatbots and context-aware support. Even scientific research can benefit from advanced data analysis and literature reviews. This AI is a game-changer, opening doors to exciting future applications.