Use Claude 3 API with Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to this coding lecture now we're going to use CLA via API and there are just a few steps the first one is that you have to sign up for the console account then we are going to look how to generate the API keys and we need to explore the API reference to find the reference code as you can see it here at the right hand side for using it via Python and then we're going to test it all right let's get started okay here we are on the page on entropic tocom and you can see that c 3 is now available and here is also the link to the API we can just click on get started now and we are directly forwarded to the console all right and here on the console we can just log in if we already have an account I will just use social login via Google all right and here we are now we can click on get API keys and I'm going to delete the other one so we are at the same page now we can create our API key just click on it let's call it my clot key click on create key then you can copy it then I'm going to set it up as an environment variable so I just looked for the system properties and here on the environment variables I'm going to create a new one I will just call it clot underline API and in here I'm going to paste the value and save it all right now we have to find out how we can use it so we can just go and head over to the docs and in here in the docs you can see the API reference now in the API reference here we have different client SDK and here's the code for python now let's head over to vs code and take this code okay and here in the sub folder 110 miscellenous I'm going to create a new file let's call it clot test.py and in here we can paste the code from before and you can see already we need to install the package entropic and at first I need to activate the environment and now we can install the package pip install and Tropic good that should be covering the package we can just test it and just load the package at first and now we need to get our API key for that we are going to use OS because we are going to fetch it from the environment variables and we can get that us Environ doget and we call it claw API all right that should be it now we can just run it and see if it's working and this is the return so we have now set up our client the subm modu messages and create we have passed the model we using here the largest one maybe we should due to pricing use another one like the Sonet model then we can also specify parameters like the maximum number of tokens and then we are setting up a message which is looking very much like the setup of openme ey so we define the role we just use a user prompt and the next key is corresponding to the content and here we have hello clot and then from this message we can extract the content and we can even go deeper to just get the message message do content at position zero do text so that would be it this is already the response from claw 3 now we can play with it a bit more we can define a bit more complicated questions like the one I showed on the slid set you want to build a team of 11 players for soccer I just want to define something which is really challenging the model so let's say all players are animals which animals in the different positions yield the best performance in a tournament now let's see how it performs on that one and here we are so we see while it's fun and creative idea to build a soccer team with animals it's important to note that in reality animals cannot play soccer in an organized manner so let's move we make it a bit nicer okay that one is better readable so it's coming up with the different positions for the goalkeeper a gorilla which is good I it earlier there I got an octopus which is making more sense even then we have cheetah elephants kangaroos honey Bater okay horses and dolphins yeah interesting compilation and yeah a fun way of challenging the model great and now we have covered nearly everything now you know how to how to connect python with it and use it from some API level if we head over again to the console then you can just go to your account and check out the usage and here on the usage page you can see how much you have already used and it's separated into input tokens and output tokens so it's really good for checking out how much you have used already and then if the yeah the two requests I just ran before cost me 4 cents if I want to make it cheaper of course I can use the different model I can use Sonet instead of oppus and if that initial money which was provided for free to me is not enough then you can of course upgrade to other plans good and that is what I wanted to show you on in Tropics clot it's really promising and I want to follow on that one because it's providing very good results and it's playing really in the same ballpark as gbd4 so yeah I can just encourage you to check this out and keep it on your radar it's making a very good first impression thanks a lot and see you in the next lecture
Info
Channel: Gollnick Data Solutions
Views: 791
Rating: undefined out of 5
Keywords:
Id: 6Smr0XlnJCE
Channel Id: undefined
Length: 9min 20sec (560 seconds)
Published: Sat Mar 09 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.